git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Remove possible segfault in http-fetch.

From
Sean <seanlkml@sympatico.ca>
Date
May 20, 2006, 22:46 UTC
Message-ID
<BAYC1-PASMTP082397700A9527CC2F3786AEA40@CEZ.ICE>
In-Reply-To
<87fyj4y1lx.fsf@mid.deneb.enyo.de>

Free the curl string lists after running http_cleanup to avoid an occasional segfault in the curl library. Seems to only occur if the website returns a 405 error.

Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
---

On Sat, 20 May 2006 20:47:54 +0200 Florian Weimer <fw@deneb.enyo.de> wrote:

Show 7 quoted lines
> Is anybody else seeing segfaults on dumb HTTP pull with
> USE_CURL_MULTI?  For example, this crashes for me:
> 
> $ git clone http://git.enyo.de/fw/debian/debfoster.git upstream
> 
> GDB shows that this happens inside the call to curl_multi_perform.
> 
Florian, could you please test this patch.

It comes with a big disclaimer because I don't really know the code in here all that well. However gdb reports the segfault happens in a strncasecmp call, and seeing as we've released a bunch of strings prior to the call....

Testing seems to confirm that the segfault is removed by this patch.

As to why the website returns a 405 error in the first place is still a mystery to me.

Sean
 http-fetch.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/http-fetch.c b/http-fetch.c
index 861644b..178f1ee 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -1269,10 +1269,10 @@ int main(int argc, char **argv)
 	if (pull(commit_id))
 		rc = 1;
 
-	curl_slist_free_all(no_pragma_header);
-
 	http_cleanup();
 
+	curl_slist_free_all(no_pragma_header);
+
 	if (corrupt_object_found) {
 		fprintf(stderr,
 "Some loose object were found to be corrupt, but they might be just\n"
-- 
1.3.GIT
Previous: Florian WeimerNext: Florian Weimer
Message 2 of 6 in “Segfaults with USE_CURL_MULTI”
  1. Florian WeimerMay 20, 2006
  2. Remove possible segfault in http-fetch.Sean, May 20, 2006
  3. Florian WeimerMay 20, 2006
  4. Junio C HamanoMay 21, 2006
  5. Nick HengeveldMay 31, 2006
  6. Pavel RoskinMay 22, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.