diff options
author | will <will@FreeBSD.org> | 2001-01-25 03:40:17 +0000 |
---|---|---|
committer | will <will@FreeBSD.org> | 2001-01-25 03:40:17 +0000 |
commit | 73de9eb2af2aa657a555f80e5ff0117fea74c064 (patch) | |
tree | b6c2570ba5d2f63cfc80e5dc2d56224115a60b14 /usr.bin | |
parent | 08392d8bb0b8be92f539033bc6c7b0d786e25543 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | usr.bin/apply/apply.c | 3 |
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; |