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

Re: [PATCH] http-push: refactor request url creation

From
Ray Chuan <rctay89@gmail.com>
Date
Jan 26, 2009, 01:52 UTC
Message-ID
<be6fef0d0901251752p5b34c053pb24dce8a35b06fce@mail.gmail.com>
In-Reply-To
<7vpribdszr.fsf@gitster.siamese.dyndns.org>
Hi,
On Mon, Jan 26, 2009 at 4:35 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
>> @@ -304,17 +312,7 @@ static void start_fetch_loose(struct
>> transfer_request *request)
>>
>>       git_SHA1_Init(&request->c);
>>
>> -     url = xmalloc(strlen(remote->url) + 50);
>> ...
>> -     strcpy(request->url, url);
>> +     request->url = get_remote_object_url(remote->url, hex, 0);
>> ...
>> -     curl_easy_setopt(slot->curl, CURLOPT_URL, url);
>> +     curl_easy_setopt(slot->curl, CURLOPT_URL, request->url);
>
> The original code gave a separate "url" to setop() but this gives the same
> string.  Does curl_easy_setop() copies the given string away?  IOW is this
> change safe?
>
curl strdup's it, so this is safe.
The stack is like this:

curl_easy_setopt calls Curl_setopt (at 391) calls setstropt (at 1566) calls strdup (at 276).

http://cool.haxx.se/cvs.cgi/curl/lib/easy.c?annotate=1.132 (for curl_easy_setopt) http://cool.haxx.se/cvs.cgi/curl/lib/url.c?annotate=1.782 (for Curl_setopt, setstropt)

-- 
Cheers,
Ray Chuan
Previous: Junio C HamanoNext: Daniel Stenberg
Message 3 of 6 in “http-push: refactor request url creation”
  1. http-push: refactor request url creationRay Chuan, Jan 25, 2009
  2. Junio C HamanoJan 25, 2009
  3. Ray ChuanJan 26, 2009
  4. Daniel StenbergJan 26, 2009
  5. Johannes SchindelinJan 26, 2009
  6. Junio C HamanoJan 27, 2009

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.