summaryrefslogtreecommitdiff
path: root/usr.bin/mg
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2007-09-11 15:47:18 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2007-09-11 15:47:18 +0000
commita8ba60ecf20c221bd24ff666339eb5edcbbbac33 (patch)
tree650532cc79cb8294b5e7739a5b61676601594950 /usr.bin/mg
parentd0c98e555e46b02b8df61047ae1c820859b23e93 (diff)
use strcspn to properly overwrite '\n' in fgets returned buffer
ok pyr@, ray@, millert@, moritz@, chl@
Diffstat (limited to 'usr.bin/mg')
-rw-r--r--usr.bin/mg/dired.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/usr.bin/mg/dired.c b/usr.bin/mg/dired.c
index ba44d6c0e8d..27c37b4bb4b 100644
--- a/usr.bin/mg/dired.c
+++ b/usr.bin/mg/dired.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dired.c,v 1.42 2006/11/01 06:02:29 ray Exp $ */
+/* $OpenBSD: dired.c,v 1.43 2007/09/11 15:47:17 gilles Exp $ */
/* This file is in the public domain. */
@@ -622,10 +622,7 @@ dired_(char *dname)
}
line[0] = line[1] = ' ';
while (fgets(&line[2], sizeof(line) - 2, dirpipe) != NULL) {
- char *p;
-
- if ((p = strchr(line, '\n')) != NULL)
- *p = '\0'; /* remove ^J */
+ line[strcspn(line, "\n")] = '\0'; /* remove ^J */
(void) addline(bp, line);
}
if (pclose(dirpipe) == -1) {