Skip to content

Directory traversal bugs

Elijah Newren via GitGitGadget git 5 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest8 patches 0 repliesNew
  2. v48 patches 7 repliesSuperseded
  3. v33 patches 3 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v28 patches15 repliesSuperseded
v18 patches4 repliesSuperseded

Changes in v5 from the cover letter

* added a comment with the rationale for allocating an extra len+1 bytes for the dirent.

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8t3011: demonstrate directory traversal failurest/t3011-common-prefixes-and-directory-traversal.sh+209 -00 replies
2/8Revert "dir.c: make 'git-status --ignored' work within leading directories"dir.c t/t7061-wtstatus-ignore.sh+7 -50 replies
3/8dir: remove stray quote character in commentdir.c+1 -10 replies
4/8dir: exit before wildcard fall-through if there is no wildcarddir.c t/t3011-common-prefixes-and-directory-traversal.sh+9 -20 replies
5/8dir: break part of read_directory_recursive() out for reusedir.c+37 -230 replies
6/8dir: fix checks on common prefix directorydir.c t/t3011-common-prefixes-and-directory-traversal.sh+59 -140 replies
7/8dir: synchronize treat_leading_path() and read_directory_recursive()dir.c t/t3011-common-prefixes-and-directory-traversal.sh t/t7061-wtstatus-ignore.sh+32 -20 replies
8/8dir: consolidate similar code in treat_directory()dir.c+7 -110 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 0/8] Directory traversal bugs

This series documents multiple fill_directory() bugs, and fixes the one that is new to 2.24.0 coming from en/clean-nested-with-ignored-topic, the rest having been around in versions of git going back up to a decade.

Changes since v4:

* added a comment with the rationale for allocating an extra len+1 bytes for the dirent.

Elijah Newren (8):
t3011: demonstrate directory traversal failures
Revert "dir.c: make 'git-status --ignored' work within leading
directories"
dir: remove stray quote character in comment
dir: exit before wildcard fall-through if there is no wildcard
dir: break part of read_directory_recursive() out for reuse
dir: fix checks on common prefix directory
dir: synchronize treat_leading_path() and read_directory_recursive()
dir: consolidate similar code in treat_directory()

 dir.c                                         | 187 ++++++++++++----
 ...common-prefixes-and-directory-traversal.sh | 209 ++++++++++++++++++
 t/t7061-wtstatus-ignore.sh                    |   9 +-
 3 files changed, 354 insertions(+), 51 deletions(-)
 create mode 100755 t/t3011-common-prefixes-and-directory-traversal.sh

base-commit: da72936f544fec5a335e66432610e4cef4430991
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-676%2Fnewren%2Fls-files-bug-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-676/newren/ls-files-bug-v5
Pull-Request: https://github.com/git/git/pull/676

Range-diff vs v4:

 1:  6d659b2302 = 1:  6d659b2302 t3011: demonstrate directory traversal failures
 2:  79f2b56174 = 2:  79f2b56174 Revert "dir.c: make 'git-status --ignored' work within leading directories"
 3:  d6f858cab1 = 3:  d6f858cab1 dir: remove stray quote character in comment
 4:  8d2d98eec3 = 4:  8d2d98eec3 dir: exit before wildcard fall-through if there is no wildcard
 5:  d2f5623bd7 = 5:  d2f5623bd7 dir: break part of read_directory_recursive() out for reuse
 6:  1f3978aa46 ! 6:  97e145489d dir: fix checks on common prefix directory
     @@ -93,6 +93,16 @@
       	if (!len)
       		return 1;
      +
     ++	/*
     ++	 * We need a manufactured dirent with sufficient space to store a
     ++	 * leading directory component of path in its d_name.  Here, we
     ++	 * assume that the dirent's d_name is either declared as
     ++	 *    char d_name[BIG_ENOUGH]
     ++	 * or that it is declared at the end of the struct as
     ++	 *    char d_name[]
     ++	 * For either case, padding with len+1 bytes at the end will ensure
     ++	 * sufficient storage space.
     ++	 */
      +	de = xcalloc(1, sizeof(struct dirent)+len+1);
      +	memset(&cdir, 0, sizeof(cdir));
      +	cdir.de = de;
 7:  542c6e5792 = 7:  5275e6d7f0 dir: synchronize treat_leading_path() and read_directory_recursive()
 8:  31079dc1cf = 8:  e4768931d0 dir: consolidate similar code in treat_directory()
Signature · 1 line
gitgitgadget