aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/apply/apply.c
diff options
context:
space:
mode:
authorWill Andrews <will@FreeBSD.org>2001-01-25 03:40:17 +0000
committerWill Andrews <will@FreeBSD.org>2001-01-25 03:40:17 +0000
commit34bc43d5326431daf05ea3b2c08415e8c577dae2 (patch)
treed58eb2a19edb8dc5e54927654257ce1b552d8185 /usr.bin/apply/apply.c
parent7a726a2dd1a8fbba7e5c2899ed07dfd65ab101f5 (diff)
downloadsrc-34bc43d5326431daf05ea3b2c08415e8c577dae2.tar.gz
src-34bc43d5326431daf05ea3b2c08415e8c577dae2.zip
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)
Notes
Notes: svn path=/head/; revision=71615
Diffstat (limited to 'usr.bin/apply/apply.c')
-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 2224e493234b..0894957c6f6a 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;