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)
This commit is contained in:
Will Andrews 2001-01-25 03:40:17 +00:00
parent 7a726a2dd1
commit 34bc43d532

View File

@ -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;