From: Johannes Schindelin Date: Tue, 29 Jan 2008 02:37:59 GMT Subject: Re: [RFH/PATCH] prefix_path(): disallow absolute paths Message-ID: In-Reply-To: <7vwspts9vj.fsf@gitster.siamese.dyndns.org> Hi, On Mon, 28 Jan 2008, Junio C Hamano wrote: > If we are touching the prefix_path(), I think we should try to make its > "ambiguous path rejection" more complete. I should have made more clear that I tried to avoid exactly that before 1.5.4, I guess. > 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++; > +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 ;-) Ciao, Dscho