summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2007-03-02 04:32:33 +0000
committerRay Lai <ray@cvs.openbsd.org>2007-03-02 04:32:33 +0000
commitee4d88ad7057b1d6bc161923816bc92e608b5112 (patch)
tree11ab32f9c00b988d7e67f57549412e979b11d5ca
parent14c53d4817d194407a6f4e37fb939e4fbbfe6104 (diff)
strlen fixes from Charles Longeau.
OK moritz@.
-rw-r--r--games/monop/getinp.c7
-rw-r--r--games/monop/monop.c7
-rw-r--r--usr.bin/make/job.c4
3 files changed, 8 insertions, 10 deletions
diff --git a/games/monop/getinp.c b/games/monop/getinp.c
index c2a3d1d27ad..f6684fe3465 100644
--- a/games/monop/getinp.c
+++ b/games/monop/getinp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getinp.c,v 1.7 2003/06/03 03:01:40 millert Exp $ */
+/* $OpenBSD: getinp.c,v 1.8 2007/03/02 04:32:32 ray Exp $ */
/* $NetBSD: getinp.c,v 1.4 1995/04/24 12:24:20 cgd Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)getinp.c 8.1 (Berkeley) 5/31/93";
#else
-static const char rcsid[] = "$OpenBSD: getinp.c,v 1.7 2003/06/03 03:01:40 millert Exp $";
+static const char rcsid[] = "$OpenBSD: getinp.c,v 1.8 2007/03/02 04:32:32 ray Exp $";
#endif
#endif /* not lint */
@@ -84,8 +84,7 @@ getinp(prompt, list)
}
continue;
}
- sp = buf + strlen(buf) - 1;
- if (*sp == '\n')
+ if ((sp = strchr(buf, '\n')) != NULL)
*sp = '\0';
for (sp = buf; *sp; sp++)
if (isupper(*sp))
diff --git a/games/monop/monop.c b/games/monop/monop.c
index 902450fea05..2392882f578 100644
--- a/games/monop/monop.c
+++ b/games/monop/monop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: monop.c,v 1.7 2003/06/03 03:01:40 millert Exp $ */
+/* $OpenBSD: monop.c,v 1.8 2007/03/02 04:32:32 ray Exp $ */
/* $NetBSD: monop.c,v 1.3 1995/03/23 08:34:52 cgd Exp $ */
/*
@@ -40,7 +40,7 @@ static const char copyright[] =
#if 0
static char sccsid[] = "@(#)monop.c 8.1 (Berkeley) 5/31/93";
#else
-static const char rcsid[] = "$OpenBSD: monop.c,v 1.7 2003/06/03 03:01:40 millert Exp $";
+static const char rcsid[] = "$OpenBSD: monop.c,v 1.8 2007/03/02 04:32:32 ray Exp $";
#endif
#endif /* not lint */
@@ -111,8 +111,7 @@ blew_it:
printf("user closed input stream, quitting...\n");
exit(0);
}
- sp = buf + strlen(buf) - 1;
- if (*sp == '\n')
+ if ((sp = strchr(buf, '\n')) != NULL)
*sp = '\0';
} while (strlen(buf) == 0);
if ((name_list[i] = play[i].name = strdup(buf)) == NULL)
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 590e3d7a093..fae802d4e54 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: job.c,v 1.60 2007/01/04 17:55:35 espie Exp $ */
+/* $OpenBSD: job.c,v 1.61 2007/03/02 04:32:32 ray Exp $ */
/* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */
/*
@@ -2055,7 +2055,7 @@ end_loop:
cp = inLine;
oendp = endp = inLine + strlen(inLine);
- if (endp[-1] == '\n') {
+ if (endp != inLine && endp[-1] == '\n') {
*--endp = '\0';
}
cp = JobOutput(job, inLine, endp, false);