summaryrefslogtreecommitdiff
path: root/src/transports/smart_protocol.c
Commit message (Collapse)AuthorAgeFilesLines
* remote: rename git_push_transfer_progress callbackEdward Thomson2019-02-221-1/+1
| | | | | | The `git_push_transfer_progress` is a callback and as such should be suffixed with `_cb` for consistency. Rename `git_push_transfer_progress` to `git_push_transfer_progress_cb`.
* indexer: use git_indexer_progress throughoutEdward Thomson2019-02-221-11/+11
| | | | | Update internal usage of `git_transfer_progress` to `git_indexer_progreses`.
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-22/+22
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* references: use new names in internal usageethomson/git_refEdward Thomson2019-01-171-1/+1
| | | | Update internal usage to use the `git_reference` names for constants.
* smart_pkt: reorder and rename parameters of `git_pkt_parse_line`Patrick Steinhardt2018-10-031-5/+5
| | | | | | | The parameters of the `git_pkt_parse_line` function are quite confusing. First, there is no real indicator what the `out` parameter is actually all about, and it's not really clear what the `bufflen` parameter refers to. Reorder and rename the parameters to make this more obvious.
* Merge pull request #4702 from tiennou/fix/coverityPatrick Steinhardt2018-07-201-1/+1
|\ | | | | Assorted Coverity fixes
| * smart: don't dereference a NULL pkt pointerEtienne Samson2018-07-061-1/+1
| | | | | | | | | | | | | | By clarifying what detect_caps returns on empty/missing packet, we can be sure there are actually refs to process. The old code could blindly dereference `first`, which might have been NULL. Reported by Coverity, CID 1393614
* | Merge pull request #4704 from nelhage/no-pkt-packPatrick Steinhardt2018-07-191-6/+0
|\ \ | |/ |/| Remove GIT_PKT_PACK entirely
| * This error case is now unneededNelson Elhage2018-06-291-6/+0
| |
* | refspec: rename `git_refspec__free` to `git_refspec__dispose`Patrick Steinhardt2018-06-291-1/+1
|/ | | | | | | | | Since commit 630a67366 (refspec: add public parsing api, 2018-02-07), we now have two functions `git_refspec_free` and `git_refspec__free`. The difference is that the first one will free the structure itself, while the second one will only free the structure's contents. Use our new `dispose` naming pattern for the latter function to help avoid confusion.
* Merge pull request #4698 from nelhage/fix-leaksEdward Thomson2018-06-271-11/+15
|\ | | | | Fix assorted leaks found via fuzzing
| * git_pkt_free: Allow freeing NULLNelson Elhage2018-06-251-9/+4
| |
| * Fix another missing git_pkt_freeNelson Elhage2018-06-251-1/+3
| |
| * wait_while_ack: use git_pkt_freeNelson Elhage2018-06-251-10/+17
| | | | | | | | | | git__free is insufficient if the packet is a git_pkt_ref or another type that requires freeing referenced structures.
* | smart protocol: correct error message capitalizationEdward Thomson2018-06-261-1/+1
| |
* | PACK packets are illegal while downloading refsNelson Elhage2018-06-241-0/+6
|/
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-101-5/+5
|
* smart: free the pkt when we fail to store itEtienne Samson2018-04-111-4/+5
|
* smart: separate error handling from pkt handlingEtienne Samson2018-04-111-7/+6
|
* smart: make out arguments explicit on recv_pktEtienne Samson2018-04-111-5/+5
|
* smart: typedef git_pkt_type and clarify recv_pkt return typeEtienne Samson2018-04-111-18/+17
|
* transports: smart: fix memory leak when skipping symbolic refsPatrick Steinhardt2017-10-091-6/+6
| | | | | | | | | | | When we setup the revision walk for negotiating references with a remote, we iterate over all references, ignoring tags and symbolic references. While skipping over symbolic references, we forget to free the looked up reference, resulting in a memory leak when the next iteration simply overwrites the variable. Fix that issue by freeing the reference at the beginning of each iteration and collapsing return paths for error and success.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* smart_protocol: fix parsing of server ACK responsesRoger Gee2017-06-101-1/+2
| | | | | | | | Fix ACK parsing in wait_while_ack() internal function. This patch handles the case where multi_ack_detailed mode sends 'ready' ACKs. The existing functionality would bail out too early, thus causing the processing of the ensuing packfile to fail if/when 'ready' ACKs were sent.
* Changes to provide option to turn off/on ofs_deltaGaurav Saral2017-02-101-1/+3
| | | | This change provides an option in git_libgit2_opt_t which can be used in git_libgit2_opts to turn off/on ofs_delta capability in libGit2
* Merge pull request #4049 from libgit2/ethomson/error_msgsCarlos Martín Nieto2017-01-131-1/+1
|\ | | | | giterr_set: consistent error messages
| * giterr_set: consistent error messagesEdward Thomson2016-12-291-1/+1
| | | | | | | | | | | | | | | | Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
* | smart_pkt: treat empty packet lines as errorPatrick Steinhardt2017-01-061-11/+0
|/ | | | | | | | | | | | | The Git protocol does not specify what should happen in the case of an empty packet line (that is a packet line "0004"). We currently indicate success, but do not return a packet in the case where we hit an empty line. The smart protocol was not prepared to handle such packets in all cases, though, resulting in a `NULL` pointer dereference. Fix the issue by returning an error instead. As such kind of packets is not even specified by upstream, this is the right thing to do.
* Fix potential use of uninitialized valuesPatrick Steinhardt2016-12-121-1/+1
|
* transports: smart: do not redeclare loop countersPatrick Steinhardt2016-12-121-4/+4
|
* transports: smart: abort receiving packets on end of streamPatrick Steinhardt2016-11-021-1/+5
| | | | | | | | | | | | When trying to receive packets from the remote, we loop until either an error distinct to `GIT_EBUFS` occurs or until we successfully parsed the packet. This does not honor the case where we are looping over an already closed socket which has no more data, leaving us in an infinite loop if we got a bogus packet size or if the remote hang up. Fix the issue by returning `GIT_EEOF` when we cannot read data from the socket anymore.
* transports: smart: abort ref announcement on early end of streamPatrick Steinhardt2016-11-021-1/+1
| | | | | | | | | | | | | | | | | | | When reading a server's reference announcements via the smart protocol, we expect the server to send multiple flushes before the protocol is finished. If we fail to receive new data from the socket, we will only return an end of stream error if we have not seen any flush yet. This logic is flawed in that we may run into an infinite loop when receiving a server's reference announcement with a bogus flush packet. E.g. assume the last flushing package is changed to not be '0000' but instead any other value. In this case, we will still await one more flush package and ignore the fact that we are not receiving any data from the socket, causing an infinite loop. Fix the issue by always returning `GIT_EEOF` if the socket indicates an end of stream.
* transports: smart: fix potential invalid memory dereferencesPatrick Steinhardt2016-06-071-0/+11
| | | | | | | | | | | | | | | | | | | | | | | When we receive a packet of exactly four bytes encoding its length as those four bytes it can be treated as an empty line. While it is not really specified how those empty lines should be treated, we currently ignore them and do not return an error when trying to parse it but simply advance the data pointer. Callers invoking `git_pkt_parse_line` are currently not prepared to handle this case as they do not explicitly check this case. While they could always reset the passed out-pointer to `NULL` before calling `git_pkt_parse_line` and determine if the pointer has been set afterwards, it makes more sense to update `git_pkt_parse_line` to set the out-pointer to `NULL` itself when it encounters such an empty packet. Like this it is guaranteed that there will be no invalid memory references to free'd pointers. As such, the issue has been fixed such that `git_pkt_parse_line` always sets the packet out pointer to `NULL` when an empty packet has been received and callers check for this condition, skipping such packets.
* Merge pull request #3574 from chescock/buffer-sideband-pack-dataCarlos Martín Nieto2016-03-241-17/+61
|\ | | | | Buffer sideband packet data
| * Only buffer if necessary.Chris Hescock2016-03-081-18/+39
| |
| * Buffer sideband packet dataChris Hescock2016-01-121-18/+41
| | | | | | | | The inner packet may be split across multiple sideband packets.
* | transports: smart: fix memory leak on OOM pathPatrick Steinhardt2016-02-181-0/+2
|/
* Fix bug in git_smart__push: push_transfer_progress cb is never calledDan Leehr2015-08-131-1/+1
| | | | The conditional checked cbs->transfer_progress then used the value in cbs->push_transfer_progress. In both cases it should be push_transfer_progress
* errors: add GIT_EEOF to indicate early EOFcmn/server-errorsCarlos Martín Nieto2015-05-201-2/+2
| | | | | | This can be used by tools to show mesages about failing to communicate with the server. The error message in this case will often contain the server's error message, as far as it managed to send anything.
* Make "Early EOF" message start with lowercaseMarius Ungureanu2015-05-141-2/+2
|
* Remove the callbacks struct from the remoteCarlos Martín Nieto2015-05-131-4/+3
| | | | | | | | | | | | | | Having the setting be different from calling its actions was not a great idea and made for the sake of the wrong convenience. Instead of that, accept either fetch options, push options or the callbacks when dealing with the remote. The fetch options are currently only the callbacks, but more options will be moved from setters and getters on the remote to the options. This does mean passing the same struct along the different functions but the typical use-case will only call git_remote_fetch() or git_remote_push() and so won't notice much difference.
* push: remove own copy of callbacksCarlos Martín Nieto2015-05-131-6/+7
| | | | | | | | | The push object knows which remote it's associated with, and therefore does not need to keep its own copy of the callbacks stored in the remote. Remove the copy and simply access the callbacks struct within the remote.
* allocations: test for overflow of requested sizeEdward Thomson2015-02-121-2/+2
| | | | | Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
* Plug some leaksJacques Germishuys2014-12-291-3/+5
|
* push: use the common refspec parsercmn/push-refspec-refactorCarlos Martín Nieto2014-11-091-6/+6
| | | | | | | | | | | There is one well-known and well-tested parser which we should use, instead of implementing parsing a second time. The common parser is also augmented to copy the LHS into the RHS if the latter is empty. The expressions test had to change a bit, as we now catch a bad RHS of a refspec locally.
* Factor 40 and 41 constants from source.Ciro Santilli2014-09-161-3/+3
|
* Several CppCat warnings fixedArkady Shapkin2014-09-031-1/+1
|
* Fix assert when receiving uncommon sideband packetPhilip Kelley2014-06-271-1/+3
|
* Plug leaks and fix a C99-ismCarlos Martín Nieto2014-05-221-4/+3
| | | | | | | We have too many places where we repeat free code, so when adding the new free to the generic code, it didn't take for the local transport. While there, fix a C99-ism that sneaked through.
* smart: store reported symrefsCarlos Martín Nieto2014-05-211-2/+56
| | | | | | | | | | | | The protocol has a capability which allows the server to tell us which refs are symrefs, so we can e.g. know which is the default branch. This capability is different from the ones we already support, as it's not setting a flag to true, but requires us to store a list of refspec-formatted mappings. This commit does not yet expose the information in the reference listing.