diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2003-06-23 03:23:41 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2003-06-23 03:23:41 +0000 |
commit | 822b697c68012e41a39169a609996ec99f0e3eec (patch) | |
tree | c4f4ae9f193de4ed45741eabd5fae8ae81eda8ff /usr.bin/grep | |
parent | 8b0835e56bda7c685f79e5b2a71f13aae3ce11d4 (diff) |
use strlcpy, not strncpy. ok deraadt@ millert@
Diffstat (limited to 'usr.bin/grep')
-rw-r--r-- | usr.bin/grep/grep.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index fe4935426f8..25b7b13103f 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.c,v 1.10 2003/06/23 02:02:41 tedu Exp $ */ +/* $OpenBSD: grep.c,v 1.11 2003/06/23 03:23:40 tedu Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -165,11 +165,10 @@ add_pattern(char *pat, size_t len) pattern_sz *= 2; pattern = grep_realloc(pattern, ++pattern_sz); } - if (pat[len-1] == '\n') + if (pat[len - 1] == '\n') --len; - pattern[patterns] = grep_malloc(len+1); - strncpy(pattern[patterns], pat, len); - pattern[patterns][len] = '\0'; + pattern[patterns] = grep_malloc(len + 1); + strlcpy(pattern[patterns], pat, len + 1); ++patterns; } |