summaryrefslogtreecommitdiffstats
path: root/usr.bin/file/print.c
diff options
context:
space:
mode:
authorgilles <gilles@openbsd.org>2007-09-11 15:47:17 +0000
committergilles <gilles@openbsd.org>2007-09-11 15:47:17 +0000
commit4fd6ed324346681d94337dd681df9264591cbde1 (patch)
tree8b58447c8de80075e5d1c091d559e5871db983c0 /usr.bin/file/print.c
parentuse strcspn to properly overwrite '\n' in fgets returned buffer (diff)
downloadwireguard-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/file/print.c')
-rw-r--r--usr.bin/file/print.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/usr.bin/file/print.c b/usr.bin/file/print.c
index 9b172d37a06..1271370d843 100644
--- a/usr.bin/file/print.c
+++ b/usr.bin/file/print.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print.c,v 1.11 2004/05/19 02:32:35 tedu Exp $ */
+/* $OpenBSD: print.c,v 1.12 2007/09/11 15:47:17 gilles Exp $ */
/*
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
@@ -42,7 +42,7 @@
#include <time.h>
#ifndef lint
-FILE_RCSID("@(#)$Id: print.c,v 1.11 2004/05/19 02:32:35 tedu Exp $")
+FILE_RCSID("@(#)$Id: print.c,v 1.12 2007/09/11 15:47:17 gilles Exp $")
#endif /* lint */
#define SZOF(a) (sizeof(a) / sizeof(a[0]))
@@ -181,7 +181,6 @@ file_fmttime(uint32_t v, int local)
pp = asctime(tm);
}
- if ((rt = strchr(pp, '\n')) != NULL)
- *rt = '\0';
+ pp[strcspn(pp, "\n")] = '\0';
return pp;
}