diff options
author | gilles <gilles@openbsd.org> | 2007-09-11 16:30:59 +0000 |
---|---|---|
committer | gilles <gilles@openbsd.org> | 2007-09-11 16:30:59 +0000 |
commit | 673a9bc7975637e3f6be7fecd5af272ae0eca252 (patch) | |
tree | 013158fdf66c24dd9b482d22fc390c18228da9cd /usr.sbin/inetd | |
parent | More 64 bits counters fixes. (diff) | |
download | wireguard-openbsd-673a9bc7975637e3f6be7fecd5af272ae0eca252.tar.xz wireguard-openbsd-673a9bc7975637e3f6be7fecd5af272ae0eca252.zip |
use strcspn to properly overwrite '\n' in fgets returned buffer
ok pyr@, ray@, millert@, moritz@, chl@
Diffstat (limited to 'usr.sbin/inetd')
-rw-r--r-- | usr.sbin/inetd/inetd.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c index b7849e882dc..7c36c3dfc25 100644 --- a/usr.sbin/inetd/inetd.c +++ b/usr.sbin/inetd/inetd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inetd.c,v 1.123 2005/04/02 18:10:52 otto Exp $ */ +/* $OpenBSD: inetd.c,v 1.124 2007/09/11 16:30:59 gilles Exp $ */ /* * Copyright (c) 1983,1991 The Regents of the University of California. @@ -37,7 +37,7 @@ char copyright[] = #ifndef lint /*static const char sccsid[] = "from: @(#)inetd.c 5.30 (Berkeley) 6/3/91";*/ -static const char rcsid[] = "$OpenBSD: inetd.c,v 1.123 2005/04/02 18:10:52 otto Exp $"; +static const char rcsid[] = "$OpenBSD: inetd.c,v 1.124 2007/09/11 16:30:59 gilles Exp $"; #endif /* not lint */ /* @@ -1494,13 +1494,9 @@ again: char * nextline(FILE *fd) { - char *cp; - if (fgets(line, sizeof (line), fd) == NULL) return (NULL); - cp = strchr(line, '\n'); - if (cp) - *cp = '\0'; + line[strcspn(line, "\n")] = '\0'; return (line); } |