freebsd-dev/usr.bin/grep
Alex Richardson 81c3f64110 usr.bin/grep: Fix Address OOB read error
I found this when compiling all the bootstrap tools with -fsanitize=addres:

==65590==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62d000008400 at pc 0x000000473053 bp 0x7ffc1c7dd910 sp 0x7ffc1c7dd0b8
READ of size 32769 at 0x62d000008400 thread T0
    #0 0x473052 in regexec (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x473052)
    #1 0x4c9cf3 in procline /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:539:8
    #2 0x4c8687 in procfile /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:379:18
    #3 0x4c6596 in main /local/scratch/alr48/cheri/freebsd/usr.bin/grep/grep.c:714:8

0x62d000008400 is located 0 bytes to the right of 32768-byte region [0x62d000000400,0x62d000008400)
allocated by thread T0 here:
    #0 0x493d5d in malloc (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x493d5d)
    #1 0x4cad75 in grep_malloc /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:656:13
    #2 0x4c8129 in procfile /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c
    #3 0x4c6596 in main /local/scratch/alr48/cheri/freebsd/usr.bin/grep/grep.c:714:8

SUMMARY: AddressSanitizer: heap-buffer-overflow (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x473052) in regexec

Reviewed By:	kevans
MFC after:	1 week
2021-02-09 17:13:32 +00:00
..
tests grep: tests: stop testing for a nonexistent version of grep 2020-12-25 15:16:33 -06:00
file.c usr.bin/grep: Fix Address OOB read error 2021-02-09 17:13:32 +00:00
grep.1 grep: turn off -w if -x is specified 2021-02-04 20:59:43 -06:00
grep.c grep: turn off -w if -x is specified 2021-02-04 20:59:43 -06:00
grep.h grep: replace the internal queue with a ring buffer 2020-12-09 05:27:45 +00:00
Makefile grep: fix LINKS in Makefile 2021-01-18 11:22:48 +01:00
Makefile.depend Update Makefile.depend files 2019-12-11 17:37:53 +00:00
Makefile.depend.options Add Makefile.depend.options 2019-12-11 17:37:37 +00:00
queue.c usr.bin/grep: Fix Address OOB read error 2021-02-09 17:13:32 +00:00
util.c grep: fix -A handling in conjunction with -m match limitation 2021-02-08 12:41:22 -06:00
zgrep.1 Fix some regressions with the zgrep(1) wrapper. 2020-07-20 23:57:53 +00:00
zgrep.sh bzgrep: make flag --no-filename work 2020-11-20 09:56:46 +00:00