diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2007-09-11 15:47:18 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2007-09-11 15:47:18 +0000 |
commit | a8ba60ecf20c221bd24ff666339eb5edcbbbac33 (patch) | |
tree | 650532cc79cb8294b5e7739a5b61676601594950 /usr.bin/rcs | |
parent | d0c98e555e46b02b8df61047ae1c820859b23e93 (diff) |
use strcspn to properly overwrite '\n' in fgets returned buffer
ok pyr@, ray@, millert@, moritz@, chl@
Diffstat (limited to 'usr.bin/rcs')
-rw-r--r-- | usr.bin/rcs/diff.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/usr.bin/rcs/diff.c b/usr.bin/rcs/diff.c index 69f8f0f6e57..1a85f589a1b 100644 --- a/usr.bin/rcs/diff.c +++ b/usr.bin/rcs/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.24 2007/07/03 00:56:23 ray Exp $ */ +/* $OpenBSD: diff.c,v 1.25 2007/09/11 15:47:17 gilles Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -1155,7 +1155,6 @@ match_function(const long *f, int pos, FILE *fp) unsigned char buf[FUNCTION_CONTEXT_SIZE]; size_t nc; int last = lastline; - char *p; char *state = NULL; lastline = pos; @@ -1167,9 +1166,9 @@ match_function(const long *f, int pos, FILE *fp) nc = fread(buf, 1, nc, fp); if (nc > 0) { buf[nc] = '\0'; - p = strchr((const char *)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) |