Re: [RFH/PATCH] prefix_path(): disallow absolute paths
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 29, 2008, 02:45 UTC
- Message-ID
- <7v7ihts61v.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <alpine.LSU.1.00.0801290234590.23907@racer.site>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 14 quoted lines
>> This is not to be applied (especially before auditing the callers), but >> to be thought about. Although it passes all the tests... > > It certainly is tempting. > > >> + while (c == '/') >> + c = *src++; >> + src--; > > This is ugly. I would like this better: > > while (src[1] == '/') > src++;
Whatever. That was just for discussion.
Show 7 quoted lines
>> +const char *prefix_path(const char *prefix, int len, const char *path)
>> +{
>> + const char *orig = path;
>> + char *sanitized = xmalloc(len + strlen(path) + 1);
>
> There _has_ to be a way to avoid malloc()ing things that will _never_ be
> free()d again with every second patch ;-)Huh? prefix_path() already allocates for rewritten pathspec entries; this is nothing new.