mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-27 13:32:45 +00:00
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:
parent
7a726a2dd1
commit
34bc43d532
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=71615
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user