summaryrefslogtreecommitdiffstats
path: root/usr.bin/apply
diff options
context:
space:
mode:
authorwill <will@FreeBSD.org>2001-01-25 03:40:17 +0000
committerwill <will@FreeBSD.org>2001-01-25 03:40:17 +0000
commit73de9eb2af2aa657a555f80e5ff0117fea74c064 (patch)
treeb6c2570ba5d2f63cfc80e5dc2d56224115a60b14 /usr.bin/apply
parent08392d8bb0b8be92f539033bc6c7b0d786e25543 (diff)
downloadFreeBSD-src-73de9eb2af2aa657a555f80e5ff0117fea74c064.zip
FreeBSD-src-73de9eb2af2aa657a555f80e5ff0117fea74c064.tar.gz
Fix bogus checking of snprintf() by decreasing the remaining size of the
string after each successful snprintf() call. This makes apply(1) work *correctly*, although the whole snprintf() deal really should be redone. Bug noted by: nectar (about 3 weeks ago)
Diffstat (limited to 'usr.bin/apply')
-rw-r--r--usr.bin/apply/apply.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/usr.bin/apply/apply.c b/usr.bin/apply/apply.c
index 2224e49..0894957 100644
--- a/usr.bin/apply/apply.c
+++ b/usr.bin/apply/apply.c
@@ -146,11 +146,13 @@ main(int argc, char *argv[]) {
if ((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)
err(1, "snprintf() failed");
p += offset;
+ cmdsize -= offset;
}
/*
@@ -197,6 +199,7 @@ main(int argc, char *argv[]) {
if ((size_t)offset >= l)
err(1, "snprintf() failed");
q += offset;
+ l -= offset;
} else
*q++ = *p;
OpenPOWER on IntegriCloud