summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/grep
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2004-07-04 14:00:25 +0000
committertjr <tjr@FreeBSD.org>2004-07-04 14:00:25 +0000
commit6380609efc2a784441844ead766e67bd862a163a (patch)
tree3411746a744f861a5ff52960e7f537a25e54cacc /gnu/usr.bin/grep
parent0b5402fc6b7225b89bf8a3dd809b4e100b3ea150 (diff)
downloadFreeBSD-src-6380609efc2a784441844ead766e67bd862a163a.zip
FreeBSD-src-6380609efc2a784441844ead766e67bd862a163a.tar.gz
Avoid accessing accessing memory past the end of mb_properties in the
degenerate case of fgrep with an empty pattern in a multibyte locale. Found by phkmalloc.
Diffstat (limited to 'gnu/usr.bin/grep')
-rw-r--r--gnu/usr.bin/grep/search.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/gnu/usr.bin/grep/search.c b/gnu/usr.bin/grep/search.c
index b8a1dcd..b2514a9 100644
--- a/gnu/usr.bin/grep/search.c
+++ b/gnu/usr.bin/grep/search.c
@@ -552,7 +552,8 @@ Fexecute (char const *buf, size_t size, size_t *match_size, int exact)
if (offset == (size_t) -1)
goto failure;
#ifdef MBS_SUPPORT
- if (MB_CUR_MAX > 1 && mb_properties[offset+beg-buf] == 0)
+ if (MB_CUR_MAX > 1 && offset + beg - buf < size
+ && mb_properties[offset+beg-buf] == 0)
continue; /* It is a part of multibyte character. */
#endif /* MBS_SUPPORT */
beg += offset;
OpenPOWER on IntegriCloud