Skip to content

Commit c13f458

Browse files
committed
Merge branch 'jk/fix-remote-curl-url-wo-proto'
"git fetch http::/site/path" did not die correctly and segfaulted instead. * jk/fix-remote-curl-url-wo-proto: remote-curl: handle URLs without protocol
2 parents 4fa1251 + d63ed6e commit c13f458

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

http.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ static CURL *get_curl_handle(void)
723723
* precedence here, as in CURL.
724724
*/
725725
if (!curl_http_proxy) {
726-
if (!strcmp(http_auth.protocol, "https")) {
726+
if (http_auth.protocol && !strcmp(http_auth.protocol, "https")) {
727727
var_override(&curl_http_proxy, getenv("HTTPS_PROXY"));
728728
var_override(&curl_http_proxy, getenv("https_proxy"));
729729
} else {

t/t5550-http-fetch-dumb.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,5 +299,13 @@ test_expect_success 'git client does not send an empty Accept-Language' '
299299
! grep "^=> Send header: Accept-Language:" stderr
300300
'
301301

302+
test_expect_success 'remote-http complains cleanly about malformed urls' '
303+
# do not actually issue "list" or other commands, as we do not
304+
# want to rely on what curl would actually do with such a broken
305+
# URL. This is just about making sure we do not segfault during
306+
# initialization.
307+
test_must_fail git remote-http http::/example.com/repo.git
308+
'
309+
302310
stop_httpd
303311
test_done

0 commit comments

Comments
 (0)