Avoid overflowing name buffer in deep directory structures
This just makes sure that when we do a read_directory(), we check that the filename fits in the buffer we allocated (with a bit of slop) Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Apr 9, 2007 at 21:13 UTC
5d5cea67af386cfd53428f1eb404841eca8e9062
1 file changed
+3
dir.c
+3
@@ -353,6 +353,9 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
353
!strcmp(de->d_name + 1, "git")))
354
continue;
355
len = strlen(de->d_name);
356
+ /* Ignore overly long pathnames! */
357
+ if (len + baselen + 8 > sizeof(fullname))
358
+ continue;
359
memcpy(fullname + baselen, de->d_name, len+1);
360
if (simplify_away(fullname, baselen + len, simplify))
361
continue;