mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04: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
1 changed files with 3 additions and 0 deletions
|
|
@ -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 a new issue