All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hui Wang <jason77.wang@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Hui Wang <jason77.wang@gmail.com>, <git@vger.kernel.org>
Subject: Re: [PATCH 1/1] clone: replace relative paths in the alternates
Date: Fri, 19 Aug 2011 14:39:23 +0800	[thread overview]
Message-ID: <4E4E051B.5020803@gmail.com> (raw)
In-Reply-To: <7vy5yp53aj.fsf@alter.siamese.dyndns.org>

Junio C Hamano wrote:
> Hui Wang <jason77.wang@gmail.com> writes:
>
>   
>> +	mapsz = xsize_t(st.st_size);
>> +	map = xmmap(NULL, mapsz, PROT_READ, MAP_PRIVATE, fd, 0);
>> +	close(fd);
>> +
>> +	tmpbuf = mapsz > 4096 ? xmalloc(mapsz * 2) : xmalloc(mapsz + 4096);
>>     
>
> Where do these magic numbers come from, and what guarantee do we have that
> these magic numbers give safe upper bound for pathnames that are expanded
> to be absolute?
>
>   
If an alternates file has dozens of relative path lines, this code has 
great risk.
> Wouldn't it be a lot cleaner and much less error prone if you open the
> original, read from it with strbuf_readline(), convert the path using
> strbuf manipulation functions and write the resulting line out to the
> lockfile you obtained to update it, line by line?
>   
This is a good suggestion, i will try to use the above way to prepare a 
V2 patch.

Thanks,
Jason.

      reply	other threads:[~2011-08-19  6:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-19  5:23 [PATCH 0/1] git-clone: fix relative path problem in the alternates Hui Wang
2011-08-19  5:23 ` [PATCH 1/1] clone: replace relative paths " Hui Wang
2011-08-19  6:22   ` Junio C Hamano
2011-08-19  6:39     ` Hui Wang [this message]

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

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

  git send-email \
    --in-reply-to=4E4E051B.5020803@gmail.com \
    --to=jason77.wang@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.