mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
Avoid signed overflow in error handling code.
Reviewed by: cperciva, bjk
This commit is contained in:
parent
ab76bc977a
commit
89c5c3aab8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=250882
|
@ -379,8 +379,10 @@ newfile(void)
|
|||
|
||||
/* maxfiles = pattlen^sufflen, but don't use libm. */
|
||||
for (maxfiles = 1, i = 0; i < sufflen; i++)
|
||||
if ((maxfiles *= pattlen) <= 0)
|
||||
if (LONG_MAX / pattlen < maxfiles)
|
||||
errx(EX_USAGE, "suffix is too long (max %ld)", i);
|
||||
else
|
||||
maxfiles *= pattlen;
|
||||
|
||||
if (fnum == maxfiles)
|
||||
errx(EX_DATAERR, "too many files");
|
||||
|
|
Loading…
Reference in a new issue