summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/config/misc.c7
-rw-r--r--usr.sbin/httpd/src/modules/standard/mod_mime_magic.c14
-rw-r--r--usr.sbin/httpd/src/support/logresolve.c6
-rw-r--r--usr.sbin/inetd/inetd.c10
-rw-r--r--usr.sbin/ppp/ppp/auth.c22
-rw-r--r--usr.sbin/pppd/chat/chat.c8
-rw-r--r--usr.sbin/sliplogin/sliplogin.c8
7 files changed, 22 insertions, 53 deletions
diff --git a/usr.sbin/config/misc.c b/usr.sbin/config/misc.c
index da9c9f69b48..4eea2190c64 100644
--- a/usr.sbin/config/misc.c
+++ b/usr.sbin/config/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.6 2006/12/06 05:05:16 ray Exp $ */
+/* $OpenBSD: misc.c,v 1.7 2007/09/11 16:30:59 gilles Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -26,7 +26,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: misc.c,v 1.6 2006/12/06 05:05:16 ray Exp $";
+static char rcsid[] = "$OpenBSD: misc.c,v 1.7 2007/09/11 16:30:59 gilles Exp $";
#endif
#include <sys/types.h>
@@ -48,8 +48,7 @@ ask_cmd(cmd_t *cmd)
/* Get input */
if (fgets(lbuf, sizeof lbuf, stdin) == NULL)
errx(1, "eof");
- if ((cp = strchr(lbuf, '\n')) != NULL)
- *cp = '\0';
+ lbuf[strcspn(lbuf, "\n")] = '\0';
if (verbose)
printf("%s\n", lbuf);
diff --git a/usr.sbin/httpd/src/modules/standard/mod_mime_magic.c b/usr.sbin/httpd/src/modules/standard/mod_mime_magic.c
index 8121e59aafa..2bf532d3b3d 100644
--- a/usr.sbin/httpd/src/modules/standard/mod_mime_magic.c
+++ b/usr.sbin/httpd/src/modules/standard/mod_mime_magic.c
@@ -933,11 +933,9 @@ static int apprentice(server_rec *s, pool *p)
/* parse it */
for (lineno = 1; fgets(line, sizeof(line), f) != NULL; lineno++) {
int ws_offset;
- char *pl;
/* delete newline */
- if ((pl = strchr(line, '\n')) != NULL)
- *pl = '\0';
+ line[strcspn(line, "\n")] = '\0';
/* skip leading whitespace */
ws_offset = 0;
@@ -1676,7 +1674,7 @@ static int match(request_rec *r, unsigned char *s, int nbytes)
static void mprint(request_rec *r, union VALUETYPE *p, struct magic *m)
{
- char *pp, *rt;
+ char *pp;
unsigned long v;
switch (m->type) {
@@ -1710,8 +1708,7 @@ static void mprint(request_rec *r, union VALUETYPE *p, struct magic *m)
case LEDATE:
/* XXX: not multithread safe */
pp = ctime((time_t *) & p->l);
- if ((rt = strchr(pp, '\n')) != NULL)
- *rt = '\0';
+ pp[strcspn(pp, "\n")] = '\0';
(void) magic_rsl_printf(r, m->desc, pp);
return;
default:
@@ -1730,8 +1727,6 @@ static void mprint(request_rec *r, union VALUETYPE *p, struct magic *m)
*/
static int mconvert(request_rec *r, union VALUETYPE *p, struct magic *m)
{
- char *rt;
-
switch (m->type) {
case BYTE:
case SHORT:
@@ -1741,8 +1736,7 @@ static int mconvert(request_rec *r, union VALUETYPE *p, struct magic *m)
case STRING:
/* Null terminate and eat the return */
p->s[sizeof(p->s) - 1] = '\0';
- if ((rt = strchr(p->s, '\n')) != NULL)
- *rt = '\0';
+ p->s[strcspn(p->s, "\n")] = '\0';
return 1;
case BESHORT:
p->h = (short) ((p->hs[0] << 8) | (p->hs[1]));
diff --git a/usr.sbin/httpd/src/support/logresolve.c b/usr.sbin/httpd/src/support/logresolve.c
index 9223043494d..df940d75d65 100644
--- a/usr.sbin/httpd/src/support/logresolve.c
+++ b/usr.sbin/httpd/src/support/logresolve.c
@@ -244,13 +244,9 @@ static void stats (FILE *output)
static int getline (char *s, int n)
{
- char *cp;
-
if (!fgets(s, n, stdin))
return (0);
- cp = strchr(s, '\n');
- if (cp)
- *cp = '\0';
+ s[strcspn(s, "\n")] = '\0';
return (1);
}
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);
}
diff --git a/usr.sbin/ppp/ppp/auth.c b/usr.sbin/ppp/ppp/auth.c
index d24da995a89..1db1ea85d9f 100644
--- a/usr.sbin/ppp/ppp/auth.c
+++ b/usr.sbin/ppp/ppp/auth.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: auth.c,v 1.20 2006/11/02 18:27:29 ray Exp $
+ * $OpenBSD: auth.c,v 1.21 2007/09/11 16:30:59 gilles Exp $
*/
#include <sys/param.h>
@@ -124,13 +124,10 @@ auth_SetPhoneList(const char *name, char *phone, int phonelen)
again:
lineno = 0;
while (fgets(buff, sizeof buff, fp)) {
- char *p;
-
lineno++;
if (buff[0] == '#')
continue;
- if ((p = strchr(buff, '\n')) != NULL)
- *p = '\0';
+ buff[strcspn(buff, "\n")] = '\0';
memset(vector, '\0', sizeof vector);
if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0)
log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
@@ -188,13 +185,10 @@ auth_Select(struct bundle *bundle, const char *name)
again:
lineno = 0;
while (fgets(buff, sizeof buff, fp)) {
- char *p;
-
lineno++;
if (buff[0] == '#')
continue;
- if ((p = strchr(buff, '\n')) != NULL)
- *p = '\0';
+ buff[strcspn(buff, "\n")] = '\0';
memset(vector, '\0', sizeof vector);
if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0)
log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
@@ -259,13 +253,10 @@ again:
lineno = 0;
if (fp != NULL) {
while (fgets(buff, sizeof buff, fp)) {
- char *p;
-
lineno++;
if (buff[0] == '#')
continue;
- if ((p = strchr(buff, '\n')) != NULL)
- *p = '\0';
+ buff[strcspn(buff, "\n")] = '\0';
memset(vector, '\0', sizeof vector);
if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0)
log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
@@ -317,14 +308,11 @@ auth_GetSecret(struct bundle *bundle, const char *name, int len,
again:
lineno = 0;
while (fgets(buff, sizeof buff, fp)) {
- char *p;
-
lineno++;
if (buff[0] == '#')
continue;
/* Trim the '\n' */
- if ((p = strchr(buff, '\n')) != NULL)
- *p = '\0';
+ buff[strcspn(buff, "\n")] = '\0';
memset(vector, '\0', sizeof vector);
if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0)
log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
diff --git a/usr.sbin/pppd/chat/chat.c b/usr.sbin/pppd/chat/chat.c
index e33cad995dc..a637c4cc8f3 100644
--- a/usr.sbin/pppd/chat/chat.c
+++ b/usr.sbin/pppd/chat/chat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chat.c,v 1.22 2004/02/26 17:46:24 deraadt Exp $ */
+/* $OpenBSD: chat.c,v 1.23 2007/09/11 16:30:59 gilles Exp $ */
/*
* Chat -- a program for automatic session establishment (i.e. dial
@@ -83,7 +83,7 @@
#if 0
static char rcsid[] = "Id: chat.c,v 1.19 1998/03/24 23:57:48 paulus Exp $";
#else
-static char rcsid[] = "$OpenBSD: chat.c,v 1.22 2004/02/26 17:46:24 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: chat.c,v 1.23 2007/09/11 16:30:59 gilles Exp $";
#endif
#endif
@@ -369,9 +369,7 @@ char *chat_file;
sendflg = 0;
while (fgets(buf, STR_LEN, cfp) != NULL) {
- sp = strchr (buf, '\n');
- if (sp)
- *sp = '\0';
+ buf[strcspn(buf, "\n")] = '\0';
linect++;
sp = buf;
diff --git a/usr.sbin/sliplogin/sliplogin.c b/usr.sbin/sliplogin/sliplogin.c
index 2d5ec497318..d7eb062d032 100644
--- a/usr.sbin/sliplogin/sliplogin.c
+++ b/usr.sbin/sliplogin/sliplogin.c
@@ -35,7 +35,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)sliplogin.c 5.6 (Berkeley) 3/2/91";*/
-static char rcsid[] = "$Id: sliplogin.c,v 1.26 2007/03/06 03:22:11 ray Exp $";
+static char rcsid[] = "$Id: sliplogin.c,v 1.27 2007/09/11 16:30:59 gilles Exp $";
#endif /* not lint */
/*
@@ -120,10 +120,8 @@ findid(char *name)
while (fgets(loginargs, sizeof(loginargs), fp)) {
if (ferror(fp))
break;
- if ((p = strchr(loginargs, '#')))
- *p = '\0';
- if ((p = strchr(loginargs, '\n')))
- *p = '\0';
+ loginargs[strcspn(loginargs, "#")] = '\0';
+ loginargs[strcspn(loginargs, "\n")] = '\0';
n = sscanf(loginargs, "%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s\n",
user, laddr, raddr, mask, slopt[0], slopt[1],
slopt[2], slopt[3], slopt[4]);