diff options
author | 2003-06-23 22:27:09 +0000 | |
---|---|---|
committer | 2003-06-23 22:27:09 +0000 | |
commit | 06b5aec29a65808a574e09c8f3dcc5a51be1039d (patch) | |
tree | b98e180aba3c6fc7fa420c56359149fd690646f6 /usr.bin/grep/grep.c | |
parent | faster grep for simple patterns. derived from a patch by sean farley. (diff) | |
download | wireguard-openbsd-06b5aec29a65808a574e09c8f3dcc5a51be1039d.tar.xz wireguard-openbsd-06b5aec29a65808a574e09c8f3dcc5a51be1039d.zip |
go back to using strncpy. for long patterns, strlcpy reads too much
of a potentially nontermined src.
Diffstat (limited to 'usr.bin/grep/grep.c')
-rw-r--r-- | usr.bin/grep/grep.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index bc75324af47..c7abfc35e3a 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.c,v 1.13 2003/06/23 22:05:23 tedu Exp $ */ +/* $OpenBSD: grep.c,v 1.14 2003/06/23 22:27:09 tedu Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -171,7 +171,8 @@ add_pattern(char *pat, size_t len) if (pat[len - 1] == '\n') --len; pattern[patterns] = grep_malloc(len + 1); - strlcpy(pattern[patterns], pat, len + 1); + strncpy(pattern[patterns], pat, len); + pattern[patterns][len] = '\0'; ++patterns; if (len > maxPatternLen) |