summaryrefslogtreecommitdiffstats
path: root/usr.bin/apply
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2001-08-20 14:46:40 +0000
committerbrian <brian@FreeBSD.org>2001-08-20 14:46:40 +0000
commit5bd90784a67de0a5e78e5bd967e2cd3d4f126cb7 (patch)
treee5d043e9d5f4a4d826f6abc4af426f8e7b4410a0 /usr.bin/apply
parent3b24d8f2afd8e1e1e8b0f3748babfb3d24a57ddb (diff)
downloadFreeBSD-src-5bd90784a67de0a5e78e5bd967e2cd3d4f126cb7.zip
FreeBSD-src-5bd90784a67de0a5e78e5bd967e2cd3d4f126cb7.tar.gz
Handle snprintf() returning -1.
MFC after: 2 weeks
Diffstat (limited to 'usr.bin/apply')
-rw-r--r--usr.bin/apply/apply.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/apply/apply.c b/usr.bin/apply/apply.c
index 1fc4796..bf0b911 100644
--- a/usr.bin/apply/apply.c
+++ b/usr.bin/apply/apply.c
@@ -143,13 +143,13 @@ main(int argc, char *argv[]) {
p = cmd;
offset = snprintf(cmd, cmdsize, EXEC "%s", argv[0]);
- if ((size_t)offset >= cmdsize)
+ if (offset < 0 || (size_t)offset >= cmdsize)
err(1, "snprintf() failed");
p += offset;
cmdsize -= offset;
for (i = 1; i <= nargs; i++) {
offset = snprintf(p, cmdsize, " %c%d", magic, i);
- if ((size_t)offset >= cmdsize)
+ if (offset < 0 || (size_t)offset >= cmdsize)
err(1, "snprintf() failed");
p += offset;
cmdsize -= offset;
@@ -163,7 +163,7 @@ main(int argc, char *argv[]) {
nargs = 1;
} else {
offset = snprintf(cmd, cmdsize, EXEC "%s", argv[0]);
- if ((size_t)offset >= cmdsize)
+ if (offset < 0 || (size_t)offset >= cmdsize)
err(1, "snprintf() failed");
nargs = n;
}
@@ -196,7 +196,7 @@ main(int argc, char *argv[]) {
if (p[0] == magic && isdigit(p[1]) && p[1] != '0') {
offset = snprintf(q, l, "%s",
argv[(++p)[0] - '0']);
- if ((size_t)offset >= l)
+ if (offset < 0 || (size_t)offset >= l)
err(1, "snprintf() failed");
q += offset;
l -= offset;
OpenPOWER on IntegriCloud