On Mon, Feb 01, 2010 at 08:39:03AM -0500, Jeff King wrote: > If you want to keep the "!p[len]" condition, then yes. If we want to > properly quote internal NULs (which again, I am not sure is of practical > use), then you would also have to make that condition "(maxlen >= 0 && > !p[len])". Which is really not that bad, but I was trying to make it > easier to read. I am OK with any of the three combinations of fixes. > > And the fact that I am using the word "combination" probably means it > should be a separate patch anyway. > > So here is the minimal patch to go on 'maint', for Junio's convenience. And here is what the "quote embedded NULs" patch would look like on top. It's actually pretty straightforward, but the more I think of it, the more I think it is probably not worthwhile. Not only are we quoting paths, which should not have embedded NULs, but it requires that the caller always pass the length explicitly, and clearly we are not doing that all or even most of the time. So while this would fix the low-level "this function quotes an arbitrary string" case, for it to be of any use all of the code paths leading to it would need to be audited to handle NUL-embedded strings. --- diff --git a/quote.c b/quote.c index 723bb4f..fc93435 100644 --- a/quote.c +++ b/quote.c @@ -213,7 +213,7 @@ static size_t quote_c_style_counted(const char *name, ssize_t maxlen, int ch; len = next_quote_pos(p, maxlen); - if (len == maxlen || !p[len]) + if (len == maxlen || (maxlen < 0 && !p[len])) break; if (!no_dq && p == name) -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html