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

Re: [PATCH] is_hfs_dotgit: loosen over-eager match of \u{..47}

From
Torsten Bögershausen <tboegi@web.de>
Date
Dec 23, 2014, 15:24 UTC
Message-ID
<54998949.9090908@web.de>
In-Reply-To
<20141223084536.GA25190@peff.net>
On 2014-12-23 09.45, Jeff King wrote:
Show 32 quoted lines
> Our is_hfs_dotgit function relies on the hackily-implemented
> next_hfs_char to give us the next character that an HFS+
> filename comparison would look at. It's hacky because it
> doesn't implement the full case-folding table of HFS+; it
> gives us just enough to see if the path matches ".git".
> 
> At the end of next_hfs_char, we use tolower() to convert our
> 32-bit code point to lowercase. Our tolower() implementation
> only takes an 8-bit char, though; it throws away the upper
> 24 bits. This means we can't have any false negatives for
> is_hfs_dotgit. We only care about matching 7-bit ASCII
> characters in ".git", and we will correctly process 'G' or
> 'g'.
> 
> However, we _can_ have false positives. Because we throw
> away the upper bits, code point \u{0147} (for example) will
> look like 'G' and get downcased to 'g'. It's not known
> whether a sequence of code points whose truncation ends up
> as ".git" is meaningful in any language, but it does not
> hurt to be more accurate here. We can just pass out the full
> 32-bit code point, and compare it manually to the upper and
> lowercase characters we care about.
> 
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> I saw Linus ask about this on G+. I had done the "no false
> negative" analysis when writing the patch, but didn't
> consider the false positive.
> 
> Another way of accomplishing the same thing is for next_hfs_char to
> continue folding case, but _only_ do so for 8-bit code points. Like:
> 

Don't we have the same possible problem under NTFS? Under Linux + VFAT ? Under all OS + VFAT ?

And would it make sense to turn this
>   return (out & 0xffffff00) ? out : tolower(out);
into this:
static ucs_char_t unicode_tolower(ucs_char_t ch) {
   return (ch & 0xffffff00) ? ch : tolower(ch);
}
And what happens if I export NTFS to Mac OS X?
(Other combinations possible)
Shouldn't fsck under all OS warn for NTFS and hfs possible attacks ?
 
Previous: Jeff KingNext: Junio C Hamano
Message 2 of 10 in “is_hfs_dotgit: loosen over-eager match of \u{..47}”
  1. is_hfs_dotgit: loosen over-eager match of \u{..47}Jeff King, Dec 23, 2014
  2. Torsten BögershausenDec 23, 2014
  3. Junio C HamanoDec 23, 2014
  4. Jeff KingDec 23, 2014
  5. Jonathan NiederDec 23, 2014
  6. Junio C HamanoDec 23, 2014
  7. Jeff KingDec 23, 2014
  8. Jeff KingDec 23, 2014
  9. Johannes SixtDec 23, 2014
  10. Jeff KingDec 23, 2014

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.