git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Problem listing GIT repository with accents

From
Jeff King <peff@peff.net>
Date
Feb 1, 2010, 13:44 UTC
Message-ID
<20100201134454.GA796@coredump.intra.peff.net>
In-Reply-To
<20100201133903.GA923@coredump.intra.peff.net>
On Mon, Feb 01, 2010 at 08:39:03AM -0500, Jeff King wrote:
Show 10 quoted lines
> 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)
Previous: Jeff KingNext: Junio C Hamano
Message 6 of 8 in “Problem listing GIT repository with accents”
  1. Ellié Computing Open Source ProgramFeb 1, 2010
  2. Jeff KingFeb 1, 2010
  3. Jeff KingFeb 1, 2010
  4. Johannes SixtFeb 1, 2010
  5. Jeff KingFeb 1, 2010
  6. Jeff KingFeb 1, 2010
  7. Junio C HamanoFeb 1, 2010
  8. Jeff KingFeb 1, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.