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

Re: [PATCH 2/2] fix http auth with multiple curl handles

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 12, 2012, 22:50 UTC
Message-ID
<7v4nso4lb3.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120412070910.GA31122@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 24 quoted lines
> ...
> I think the best we can do is to put the auth data in a static buffer
> and feed that to curl. We end up rewriting the auth data into our buffer
> over and over, but at least we don't re-malloc it. Like this:
>
> diff --git a/http.c b/http.c
> index f3f83d7..374c3bb 100644
> --- a/http.c
> +++ b/http.c
> @@ -211,12 +211,12 @@ static int http_options(const char *var, const char *value, void *cb)
>  static void init_curl_http_auth(CURL *result)
>  {
>  	if (http_auth.username) {
> -		struct strbuf up = STRBUF_INIT;
> +		static struct strbuf up = STRBUF_INIT;
>  		credential_fill(&http_auth);
> +		strbuf_reset(&up);
>  		strbuf_addf(&up, "%s:%s",
>  			    http_auth.username, http_auth.password);
> -		curl_easy_setopt(result, CURLOPT_USERPWD,
> -				 strbuf_detach(&up, NULL));
> +		curl_easy_setopt(result, CURLOPT_USERPWD, up.buf);
>  	}
>  }

Yeah, that's sad but I agree that is probably the best we could do. Do you want me to squash it in?

Show 6 quoted lines
> By the way, this touches on an area that I noticed while refactoring the
> http auth code a while ago, but decided not to tackle at the time. We
> fill in the auth information early, and then never bother to revisit it
> as URLs change. So for example, if I got a redirect from host A to host
> B, we would continue to use the credential for host A and host B. Which
> is maybe convenient, and maybe a security issue.
Good point.  Do we follow redirects, though?
Previous: Jeff KingNext: Jeff King
Message 9 of 12 in “Cannot clone the git repository shared over http with authorization.”
  1. Artur R. CzechowskiApr 1, 2012
  2. Clemens BuchacherApr 1, 2012
  3. Clemens BuchacherApr 1, 2012
  4. Jeff KingApr 2, 2012
  5. Clemens BuchacherApr 10, 2012
  6. 1/2 http auth fails with multiple curl handlesClemens Buchacher, Apr 10, 2012
  7. 2/2 fix http auth with multiple curl handlesClemens Buchacher, Apr 10, 2012
  8. Jeff KingApr 12, 2012
  9. Junio C HamanoApr 12, 2012
  10. Jeff KingApr 13, 2012
  11. 1/2 http: clean up leak in init_curl_http_authJeff King, Apr 13, 2012
  12. 2/2 http: use newer curl options for setting credentialsJeff King, Apr 13, 2012

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.