git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Anton Wuerfel <anton.wuerfel@fau.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Anton Wuerfel <anton.wuerfel@fau.de>,
	Phillip@i4.informatik.uni-erlangen.de,
	"Raffeck <phillip.raffeck"@fau.de, i4passt@cs.fau.de,
	git@vger.kernel.org
Subject: [PATCH 1/1] http: Fix crash when passing malformed URL
Date: Wed, 16 Mar 2016 11:54:07 +0100	[thread overview]
Message-ID: <1458125647-32707-2-git-send-email-anton.wuerfel@fau.de> (raw)
In-Reply-To: <1458125647-32707-1-git-send-email-anton.wuerfel@fau.de>

When passing a malformed URL to http_init() in http.c, git dies from a null
pointer dereference. An example for a malformed URL is http:/git-scm.com (note
the single slash after the protocol).
This patch adds simple error handling as git notices the malformed URL already,
but never checks the error value.

When passing a malformed URL, credential_from_url(struct credential *c, const char *url)
initializes *c with null values. When the existence of `://` in url is checked,
the function returns without further change of *c.
The null pointer dereference occurs in get_curl_handle () at http.c:593, when
the `protocol` field of struct credential is strcmp'ed:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000405efd in get_curl_handle () at http.c:593
593                     if (!strcmp(http_auth.protocol, "https")) {
---
 http.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/http.c b/http.c
index 69da445..80cf752 100644
--- a/http.c
+++ b/http.c
@@ -660,6 +660,9 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
 
 	http_is_verbose = 0;
 	normalized_url = url_normalize(url, &config.url);
+	
+	if (config.url.err)
+		die(_("libcurl: %s, URL: %s"), config.url.err, url);
 
 	git_config(urlmatch_config_entry, &config);
 	free(normalized_url);
-- 
2.8.0.rc1.108.g7827469

  reply	other threads:[~2016-03-16 10:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 10:54 [PATCH 0/1] http: Fix crash when passing malformed URL Anton Wuerfel
2016-03-16 10:54 ` Anton Wuerfel [this message]
2016-03-16 21:42   ` [PATCH 1/1] " Jeff King
2016-03-16 21:29 ` [PATCH 0/1] " Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458125647-32707-2-git-send-email-anton.wuerfel@fau.de \
    --to=anton.wuerfel@fau.de \
    --cc="Raffeck <phillip.raffeck"@fau.de \
    --cc=Phillip@i4.informatik.uni-erlangen.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=i4passt@cs.fau.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).