diff options
author | 2007-09-11 15:47:17 +0000 | |
---|---|---|
committer | 2007-09-11 15:47:17 +0000 | |
commit | 4fd6ed324346681d94337dd681df9264591cbde1 (patch) | |
tree | 8b58447c8de80075e5d1c091d559e5871db983c0 /usr.bin/diff/diffreg.c | |
parent | use strcspn to properly overwrite '\n' in fgets returned buffer (diff) | |
download | wireguard-openbsd-4fd6ed324346681d94337dd681df9264591cbde1.tar.xz wireguard-openbsd-4fd6ed324346681d94337dd681df9264591cbde1.zip |
use strcspn to properly overwrite '\n' in fgets returned buffer
ok pyr@, ray@, millert@, moritz@, chl@
Diffstat (limited to 'usr.bin/diff/diffreg.c')
-rw-r--r-- | usr.bin/diff/diffreg.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 4bb8d9e1d74..53209117025 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.69 2007/06/09 05:16:21 ray Exp $ */ +/* $OpenBSD: diffreg.c,v 1.70 2007/09/11 15:47:17 gilles Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -65,7 +65,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.69 2007/06/09 05:16:21 ray Exp $"; +static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.70 2007/09/11 15:47:17 gilles Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -1300,7 +1300,6 @@ match_function(const long *f, int pos, FILE *file) unsigned char buf[FUNCTION_CONTEXT_SIZE]; size_t nc; int last = lastline; - char *p; char *state = NULL; lastline = pos; @@ -1312,9 +1311,8 @@ match_function(const long *f, int pos, FILE *file) nc = fread(buf, 1, nc, file); if (nc > 0) { buf[nc] = '\0'; - p = strchr(buf, '\n'); - if (p != NULL) - *p = '\0'; + buf[strcspn(buf, "\n")] = '\0'; + if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') { if (begins_with(buf, "private:")) { if (!state) |