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

[PATCH] Work around curl-gnutls not liking to be reinitialized

From
Mike Hommey <mh@glandium.org>
Date
Feb 8, 2008, 23:08 UTC
Message-ID
<1202512124-28669-1-git-send-email-mh@glandium.org>
In-Reply-To
<alpine.LSU.1.00.0802082250550.11591@racer.site>

curl versions 7.16.3 to 7.18.0 included had a regression in which https requests following curl_global_cleanup/init sequence would fail with ASN1 parser errors with curl-gnutls. Such sequences happen in some cases such as git fetch.

We work around this by removing the http_cleanup call from get_refs_via_curl for the broken versions of curl, and allowing http_init to be called several times without initializing http.c global variables again and leaking old values, which is a safe thing to have unconditionally.

The remaining calls to http_cleanup are either last (http-push.c), or almost never called (walker.c; the function it lies in is only called from transport-disconnect, which is called last, and only in builtin-push.c) These leaks shall be addressed in the http code refactoring.

Signed-off-by: Mike Hommey <mh@glandium.org>
---
 > Don't you have to make this conditional on the CURL version as well?  I
 > mean, that cleanup:
 > > diff --git a/transport.c b/transport.c
 > > index babaa21..32ab521 100644
 > > --- a/transport.c
 > > +++ b/transport.c
 > > @@ -473,7 +473,9 @@ static struct ref *get_refs_via_curl(struct transport *transport)
 > >              return NULL;
 > >      }
 > >
 > > +#if (LIBCURL_VERSION_NUM < 0x071003) || (LIBCURL_VERSION_NUM > 0x071200)
 > >       http_cleanup();
 > > +#endif
 >
 > requires us to init again, no?
 Damn, you're right. But it would actually be better to just have the init
 variable set to 0 again in http_cleanup, and actually, we already have a
 global variable that is set in http_init and reset in http_cleanup that
 could be used for this test...
 http.c      |    3 +++
 transport.c |    2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/http.c b/http.c
index d2c11ae..d69ba90 100644
--- a/http.c
+++ b/http.c
@@ -218,6 +218,9 @@ void http_init(void)
 	char *low_speed_limit;
 	char *low_speed_time;
 
+	if (pragma_header)
+		return;
+
 	curl_global_init(CURL_GLOBAL_ALL);
 
 	pragma_header = curl_slist_append(pragma_header, "Pragma: no-cache");
diff --git a/transport.c b/transport.c
index babaa21..32ab521 100644
--- a/transport.c
+++ b/transport.c
@@ -473,7 +473,9 @@ static struct ref *get_refs_via_curl(struct transport *transport)
 		return NULL;
 	}
 
+#if (LIBCURL_VERSION_NUM < 0x071003) || (LIBCURL_VERSION_NUM > 0x071200)
 	http_cleanup();
+#endif
 
 	data = buffer.buf;
 	start = NULL;
-- 
1.5.4.8.g95ac
Previous: Johannes SchindelinNext: Mike Hommey
Message 22 of 44 in “git-fetch in 1.5.4 fails versus 1.5.3.8”
  1. Anand KumriaFeb 4, 2008
  2. Jeff KingFeb 5, 2008
  3. Jari AaltoFeb 5, 2008
  4. Anand KumriaFeb 6, 2008
  5. Jeff KingFeb 7, 2008
  6. Mike HommeyFeb 7, 2008
  7. Anand KumriaFeb 7, 2008
  8. Jeff KingFeb 7, 2008
  9. Mike HommeyFeb 7, 2008
  10. Jeff KingFeb 7, 2008
  11. Mike HommeyFeb 7, 2008
  12. Jeff KingFeb 8, 2008
  13. Mike HommeyFeb 8, 2008
  14. Mike HommeyFeb 8, 2008
  15. Work around curl-gnutls not liking to be reinitializedMike Hommey, Feb 8, 2008
  16. Mike HommeyFeb 8, 2008
  17. Junio C HamanoFeb 8, 2008
  18. Mike HommeyFeb 8, 2008
  19. Mike HommeyFeb 8, 2008
  20. Work around curl-gnutls not liking to be reinitializedMike Hommey, Feb 8, 2008
  21. Johannes SchindelinFeb 8, 2008
  22. Work around curl-gnutls not liking to be reinitializedMike Hommey, Feb 8, 2008
  23. Mike HommeyFeb 8, 2008
  24. Work around curl-gnutls not liking to be reinitializedMike Hommey, Feb 9, 2008
  25. Daniel StenbergFeb 9, 2008
  26. Florian WeimerFeb 9, 2008
  27. Mike HommeyFeb 9, 2008
  28. Johannes SchindelinFeb 8, 2008
  29. Mike HommeyFeb 8, 2008
  30. Jeff KingFeb 9, 2008
  31. Frank LichtenheldFeb 7, 2008
  32. Linus TorvaldsFeb 7, 2008
  33. Frank LichtenheldFeb 7, 2008
  34. Linus TorvaldsFeb 7, 2008
  35. Anand KumriaFeb 7, 2008
  36. Jeff KingFeb 7, 2008
  37. Linus TorvaldsFeb 7, 2008
  38. Martin LanghoffFeb 7, 2008
  39. Dmitry PotapovFeb 7, 2008
  40. Jeff KingFeb 7, 2008
  41. Jeff KingFeb 7, 2008
  42. Dmitry PotapovFeb 7, 2008
  43. Anand KumriaFeb 8, 2008
  44. Dmitry PotapovFeb 8, 2008

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.