diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2010-04-25 14:13:37 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2010-04-25 14:13:37 +0000 |
commit | 1f3bd66aa0fe3f4886dbc53befdda18a7c5ae27f (patch) | |
tree | ff3e1eb595137315bf9c6a2865c2d6dc900c5fb0 /usr.bin/grep | |
parent | 90db213cef1e49c5ec96185846e7eec4f215bded (diff) |
prevent out-of-bounds access with empty pattern (fixes "grep -x ''")
ok millert@ krw@
Diffstat (limited to 'usr.bin/grep')
-rw-r--r-- | usr.bin/grep/util.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c index 39e8ea346f7..eb9da8b74ee 100644 --- a/usr.bin/grep/util.c +++ b/usr.bin/grep/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.37 2010/04/05 03:03:55 tedu Exp $ */ +/* $OpenBSD: util.c,v 1.38 2010/04/25 14:13:36 eric Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -279,7 +279,7 @@ fastcomp(fastgrep_t *fg, const char *pattern) fg->reversedSearch = 0; /* Remove end-of-line character ('$'). */ - if (pattern[fg->patternLen - 1] == '$') { + if (fg->patternLen > 0 && pattern[fg->patternLen - 1] == '$') { eol++; fg->eol = 1; fg->patternLen--; |