Re: [RFH/PATCH] prefix_path(): disallow absolute paths

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [RFH/PATCH] prefix_path(): disallow absolute paths

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:08

Johannes Schindelin [off-list ref] writes:
quoted
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.

quoted
+			while (c == '/')
+				c = *src++;
+			src--;
This is ugly.  I would like this better:

			while (src[1] == '/')
				src++;
Whatever.  That was just for discussion.
quoted
+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.

Re: [RFH/PATCH] prefix_path(): disallow absolute paths

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:44:08

Hi,

On Mon, 28 Jan 2008, Junio C Hamano wrote:
Johannes Schindelin [off-list ref] writes:
quoted
quoted
+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.
Right.  It is nothing new.  Except that we now allocate for more paths 
than before.

At the same time as introducing a new feature (path normalisation), we 
could introduce another change, which would introduce a function 
cleanup_prefixed_pathspecs(), which would free all path that were 
malloc()ed.

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help