Revision 447ac906e189535e77dcb1f4bbe3f1bc917d4c12 authored by Patrick Steinhardt on 01 December 2022, 14:45:31 UTC, committed by Junio C Hamano on 05 December 2022, 06:14:16 UTC
The `struct attr_stack` tracks the stack of all patterns together with their attributes. When parsing a gitattributes file that has more than 2^31 such patterns though we may trigger multiple out-of-bounds reads on 64 bit platforms. This is because while the `num_matches` variable is an unsigned integer, we always use a signed integer to iterate over them. I have not been able to reproduce this issue due to memory constraints on my systems. But despite the out-of-bounds reads, the worst thing that can seemingly happen is to call free(3P) with a garbage pointer when calling `attr_stack_free()`. Fix this bug by using unsigned integers to iterate over the array. While this makes the iteration somewhat awkward when iterating in reverse, it is at least better than knowingly running into an out-of-bounds read. While at it, convert the call to `ALLOC_GROW` to use `ALLOC_GROW_BY` instead. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 34ace8b
File | Mode | Size |
---|---|---|
nedmalloc | ||
poll | ||
regex | ||
vcbuild | ||
win32 | ||
access.c | -rw-r--r-- | 669 bytes |
apple-common-crypto.h | -rw-r--r-- | 2.7 KB |
basename.c | -rw-r--r-- | 1.3 KB |
bswap.h | -rw-r--r-- | 4.4 KB |
compiler.h | -rw-r--r-- | 897 bytes |
fileno.c | -rw-r--r-- | 117 bytes |
fopen.c | -rw-r--r-- | 938 bytes |
hstrerror.c | -rw-r--r-- | 530 bytes |
inet_ntop.c | -rw-r--r-- | 4.8 KB |
inet_pton.c | -rw-r--r-- | 6.8 KB |
memmem.c | -rw-r--r-- | 752 bytes |
mingw.c | -rw-r--r-- | 76.3 KB |
mingw.h | -rw-r--r-- | 16.9 KB |
mkdir.c | -rw-r--r-- | 468 bytes |
mkdtemp.c | -rw-r--r-- | 153 bytes |
mmap.c | -rw-r--r-- | 711 bytes |
msvc.c | -rw-r--r-- | 113 bytes |
msvc.h | -rw-r--r-- | 823 bytes |
obstack.c | -rw-r--r-- | 13.6 KB |
obstack.h | -rw-r--r-- | 19.2 KB |
pread.c | -rw-r--r-- | 433 bytes |
precompose_utf8.c | -rw-r--r-- | 4.6 KB |
precompose_utf8.h | -rw-r--r-- | 1.3 KB |
qsort_s.c | -rw-r--r-- | 1.3 KB |
setenv.c | -rw-r--r-- | 862 bytes |
sha1-chunked.c | -rw-r--r-- | 362 bytes |
sha1-chunked.h | -rw-r--r-- | 81 bytes |
snprintf.c | -rw-r--r-- | 1.5 KB |
stat.c | -rw-r--r-- | 1.1 KB |
strcasestr.c | -rw-r--r-- | 431 bytes |
strdup.c | -rw-r--r-- | 169 bytes |
strlcpy.c | -rw-r--r-- | 247 bytes |
strtoimax.c | -rw-r--r-- | 214 bytes |
strtoumax.c | -rw-r--r-- | 217 bytes |
terminal.c | -rw-r--r-- | 8.2 KB |
terminal.h | -rw-r--r-- | 256 bytes |
unsetenv.c | -rw-r--r-- | 591 bytes |
win32.h | -rw-r--r-- | 878 bytes |
win32mmap.c | -rw-r--r-- | 1.1 KB |
winansi.c | -rw-r--r-- | 16.5 KB |
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...