summaryrefslogtreecommitdiff
path: root/src/netops.c
Commit message (Collapse)AuthorAgeFilesLines
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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.
* giterr_set: consistent error messagesEdward Thomson2016-12-291-4/+4
| | | | | | | | 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
* netops: make the path optional in URLsCarlos Martín Nieto2016-04-191-10/+12
| | | | | | When we're dealing with proxy addresses, we only want a hostname and port, and the user would not provide a path, so make it optional so we can use this same function to parse git as well as proxy URLs.
* netops: fix memory leak when an error occursPatrick Steinhardt2016-02-181-0/+4
|
* git__tolower: a tolower() that isn't dumbEdward Thomson2015-05-291-3/+3
| | | | | | | | Some brain damaged tolower() implementations appear to want to take the locale into account, and this may require taking some insanely aggressive lock on the locale and slowing down what should be the most trivial of trivial calls for people who just want to downcase ASCII.
* gitno: remove code which is no longer neededCarlos Martín Nieto2014-12-101-486/+11
| | | | | | Most of the network-facing facilities have been copied to the socket and openssl streams. No code now uses these functions directly anymore, so we can now remove them.
* Port the TCP transport to the new stream APICarlos Martín Nieto2014-12-101-0/+19
|
* netops: return GIT_ECERTIFICATE when it fails the basic testscmn/invalid-cert-returnCarlos Martín Nieto2014-11-021-1/+1
| | | | | | | | When we first ask OpenSSL to verify the certfiicate itself (rather than the HTTPS specifics), we should also return GIT_ECERTIFICATE. Otherwise, the caller would consider this as a failed operation rather than a failed validation and not call the user's own validation.
* Correctly handle getaddrinfo return resultWilliam Swanson2014-09-241-1/+1
| | | | | | The getaddrinfo function indicates failure with a non-zero return code, but this code is not necessarily negative. On platforms like Android where the code is positive, a failed call causes libgit2 to segfault.
* net: remove support for outright ignoring certificatesCarlos Martín Nieto2014-09-161-5/+2
| | | | | | | | | | This option make it easy to ignore anything about the server we're connecting to, which is bad security practice. This was necessary as we didn't use to expose detailed information about the certificate, but now that we do, we should get rid of this. If the user wants to ignore everything, they can still provide a callback which ignores all the information passed.
* Provide a callback for certificate validationCarlos Martín Nieto2014-09-161-3/+4
| | | | | | | | | If the certificate validation fails (or always in the case of ssh), let the user decide whether to allow the connection. The data structure passed to the user is the native certificate information from the underlying implementation, namely OpenSSL or WinHTTP.
* in_addr is defined in <Winsock2.h>, include before <ws2tcpip.h>Jacques Germishuys2014-07-061-0/+1
|
* netops: error out on url without a pathcmn/http-url-pathCarlos Martín Nieto2014-07-031-0/+3
| | | | | | In order to connect to a remote server, we need to provide a path to the repository we're interested in. Consider the lack of path in the url an error.
* ssl: init everything all the timecmn/init-ssl-onceCarlos Martín Nieto2014-06-121-80/+3
| | | | | | | | Bring together all of the OpenSSL initialization to git_threads_init() so it's together and doesn't need locks. Moving it here also gives us libssh2 thread safety (when built against openssl).
* ssl: cargo-cult thread safetyCarlos Martín Nieto2014-06-121-22/+21
| | | | OpenSSL's tests init everything in the main thread, so let's do that.
* ssl: use lockingCarlos Martín Nieto2014-06-111-0/+42
| | | | | | | | When using in a multithreaded context, OpenSSL needs to lock, and leaves it up to application to provide said locks. We were not doing this, and it's just luck that's kept us from crashing up to now.
* netops: init OpenSSL once under lockCarlos Martín Nieto2014-06-111-2/+32
| | | | | | | | The OpenSSL init functions are not reentrant, which means that running multiple fetches in parallel can cause us to crash. Use a mutex to init OpenSSL, and since we're adding this extra checks, init it only once.
* Win32 fix for #2300.Albert Meltzer2014-05-121-0/+4
| | | | The code doesn't use SSL and a test requires it.
* netops: catch the server not sending a certificatecmn/match-host-testsCarlos Martín Nieto2014-04-261-0/+4
| | | | | | | | | | It's possible for an encrypted connection not have a certificate. In this case, SSL_get_verify_result() will return OK because no error happened (as it never even tried to validate anything). SSL_get_peer_certificate() will return NULL in this case so we need to catch that. On the upside, the current code would segfault in this situation instead of letting it through as a valid cert.
* netops: provide more specific error for cert failureCarlos Martín Nieto2014-04-261-5/+5
| | | | | Specify what we do not like about the certificate. In this case, we do not like the name.
* netops: unit-test the cert host-name pattern matchingCarlos Martín Nieto2014-04-261-4/+4
| | | | | This kind of stuff should have unit tests, even if it's just to show what we expect to match successfully.
* netops: fix leakCarlos Martín Nieto2013-11-181-2/+5
|
* Fix warningsRussell Belfer2013-11-131-1/+1
|
* Fix warningsLinquize2013-11-121-1/+1
|
* Make url decoding more bulletproofbetter-url-parsingBen Straub2013-11-051-12/+7
|
* Remove unnecessary checkBen Straub2013-11-051-1/+1
|
* Incorporate feedbackBen Straub2013-11-051-5/+5
|
* Unescape url-encoded usernames and passwordsBen Straub2013-11-041-2/+26
|
* Use http_parser_parse_url to parse urlsBen Straub2013-11-041-46/+43
|
* Clarify parsing issues and errorsBen Straub2013-11-011-2/+3
|
* Streamline url-parsing logic.Ben Straub2013-11-011-25/+25
|
* Prevent another segfault from bad URLBen Straub2013-10-311-1/+1
|
* Prevent segfault with a badly-formed URLBen Straub2013-10-311-3/+4
|
* HTTP: handle "relative" redirectsBen Straub2013-10-021-0/+10
|
* Tighten up url-connection utilityBen Straub2013-09-261-8/+2
|
* Deploy gitno_connection_data into transport (winhttp)Ben Straub2013-09-261-7/+15
| | | | ...and have that call manage replaced memory in the output structure.
* Migrate redirect URL handling to common utilityBen Straub2013-09-251-0/+75
|
* Disconnect path string to preserve after redirectRussell Belfer2013-09-241-5/+1
| | | | | | | | | | | | The subtransport path was relying on pointing to data owned by the remote which meant that after a redirect, the updated path was getting lost for future requests. This updates the http transport to strdup the path and maintain its own lifetime. This also pulls responsibility for parsing the URL back into the http transport and isolates the functions that parse and free that connection data so that they can be reused between the initial parsing and the redirect parsing.
* Properly parse urls that include protocol://Ben Straub2013-09-241-1/+4
|
* netops: remove duplicate includeFraser Tweedale2013-08-241-4/+0
| | | | | | 9e9aee6 added an include <netinet/in.h> to fix the build on FreeBSD. Sometime since then the same header is included ifndef _WIN32, so remove the duplicate include.
* Merge pull request #1298 from ben/user-atRussell Belfer2013-02-041-5/+32
|\ | | | | Handle "user@" prefix for credentials partially included in URLs
| * Introduce git__substrdupBen Straub2013-02-011-5/+5
| |
| * Enhance url parsing to include passwordsBen Straub2013-01-311-10/+28
| |
| * Stash username from url (but don't use it yet)Ben Straub2013-01-301-2/+7
| |
| * Skip "user@" when finding hostname in urlBen Straub2013-01-301-2/+6
| |
* | Deduplicate FormatMessage UTF-16 to UTF-8 conversion codeSven Strickroth2013-02-021-19/+6
| | | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | Improved error handlingSven Strickroth2013-02-021-2/+10
| | | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | Get utf8_size from WideCharToMultiByte instead of guessing itSven Strickroth2013-02-011-3/+3
| | | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | Win32: Make sure error messages are consistently UTF-8 encodedSven Strickroth2013-02-011-6/+10
|/ | | | | | | | W/o this a libgit2 error message could have a mixed encoding: e.g. a filename in UTF-8 combined with a native Windows error message encoded with the local code page. Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Fix 3 memory leaksPhilip Kelley2013-01-251-0/+1
|