summaryrefslogtreecommitdiff
path: root/usr.bin/apply/apply.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2005-02-24 12:56:16 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2005-02-24 12:56:16 +0000
commit2d4583b86fcb80319958b088bb5fa24935263af5 (patch)
treef527f5b61649961d135b1c5b02ed62ed89818ec9 /usr.bin/apply/apply.c
parent51f873ed1f95a722c31a23c3235978deba558761 (diff)
Store result of snprintf() in a signed type and check it for -1.
Do not depend on errno being set for snprintf, use errx() instead of err(). ok otto@, earlier version ok deraadt@ some time ago
Diffstat (limited to 'usr.bin/apply/apply.c')
-rw-r--r--usr.bin/apply/apply.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/apply/apply.c b/usr.bin/apply/apply.c
index b57ac0e2700..dc7da469a84 100644
--- a/usr.bin/apply/apply.c
+++ b/usr.bin/apply/apply.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apply.c,v 1.18 2004/09/14 22:21:57 deraadt Exp $ */
+/* $OpenBSD: apply.c,v 1.19 2005/02/24 12:56:15 jsg Exp $ */
/* $NetBSD: apply.c,v 1.3 1995/03/25 03:38:23 glass Exp $ */
/*-
@@ -37,7 +37,7 @@
#if 0
static const char sccsid[] = "@(#)apply.c 8.4 (Berkeley) 4/4/94";
#else
-static const char rcsid[] = "$OpenBSD: apply.c,v 1.18 2004/09/14 22:21:57 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: apply.c,v 1.19 2005/02/24 12:56:15 jsg Exp $";
#endif
#endif /* not lint */
@@ -116,22 +116,22 @@ main(int argc, char *argv[])
err(1, NULL);
if (n == 0) {
- size_t l;
+ int l;
/* If nargs not set, default to a single argument. */
if (nargs == -1)
nargs = 1;
l = snprintf(cmd, len, "exec %s", argv[0]);
- if (l >= len)
- err(1, "snprintf");
+ if (l >= len || l == -1)
+ errx(1, "error building exec string");
len -= l;
p = cmd + l;
for (i = 1; i <= nargs; i++) {
l = snprintf(p, len, " %c%d", magic, i);
- if (l >= len)
- err(1, "snprintf");
+ if (l >= len || l == -1)
+ errx(1, "error numbering arguments");
len -= l;
p += l;
}