mirror of
https://git.freebsd.org/src.git
synced 2026-01-11 19:57:22 +00:00
runat.c: Add an explicit check for snprintf() failure
The check for "outsiz" too large was probably sufficient to
catch failures, since it was cast to an unsigned (size_t).
However, it seems appropriate to add an explicit check for
a failed case (returning -1).
Discussed with: oshogbo
Fixes: 0660de8172 ("runat: Add a runat(1) utility similar to the Solaris one")
This commit is contained in:
parent
48578dcb6b
commit
511de5b143
1 changed files with 2 additions and 0 deletions
|
|
@ -52,6 +52,8 @@ main(int argc, char *argv[])
|
|||
pos = 0;
|
||||
for (i = 1; i < argc; i++) {
|
||||
outsiz = snprintf(&buf[pos], siz, "%s ", argv[i]);
|
||||
if (outsiz <= 0)
|
||||
errx(1, "snprintf failed: returned %d", outsiz);
|
||||
if ((size_t)outsiz > siz)
|
||||
errx(1, "Arguments too large");
|
||||
pos += outsiz;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue