]> git.99rst.org Git - git.git/commit
precompose_utf8: use a flex array for d_name
authorIhar Hrachyshka <redacted>
Sat, 4 Jul 2026 23:37:24 +0000 (19:37 -0400)
committerJunio C Hamano <redacted>
Sun, 5 Jul 2026 00:59:36 +0000 (17:59 -0700)
commit1eb281159f0f75044e9e45a47d1d34162f3b0032
treed01c5395342bcc7de9e056b000f5666a167cef40
parent67ad42147a7acc2af6074753ebd03d904476118f
precompose_utf8: use a flex array for d_name

On macOS, git status may abort while reading a directory entry
whose UTF-8 name grows past NAME_MAX bytes:

  __chk_fail_overflow
  __strlcpy_chk
  precompose_utf8_readdir
  read_directory_recursive
  wt_status_collect
  cmd_status

The precompose wrapper already reallocates dirent_prec_psx for
long names, but d_name is declared as char[NAME_MAX + 1]. A
fortified libc can still see that declared object size and reject a
larger strlcpy bound, even though the allocation was grown.

Make d_name a FLEX_ARRAY and size allocations from offsetof(). That
matches the actual object layout with the dynamic allocation, so the
fortified copy sees a destination whose size can grow with max_name_len.

Add a regression test that creates an over-NAME_MAX non-ASCII basename
and runs status with core.precomposeunicode enabled.

Signed-off-by: Ihar Hrachyshka <redacted>
Signed-off-by: Junio C Hamano <redacted>
compat/precompose_utf8.c
compat/precompose_utf8.h
t/t3910-mac-os-precompose.sh
git clone https://git.99rst.org/PROJECT