diff options
author | eadler <eadler@FreeBSD.org> | 2013-05-21 19:56:03 +0000 |
---|---|---|
committer | eadler <eadler@FreeBSD.org> | 2013-05-21 19:56:03 +0000 |
commit | b6bdb6d2f3ebdde975a369669792021f70118a50 (patch) | |
tree | c79905058c16d5132529a8f144d5e329c11c7a65 /usr.bin | |
parent | 4024f68eb0badf8b8b682eaf7a35f2d69a008c2a (diff) | |
download | FreeBSD-src-b6bdb6d2f3ebdde975a369669792021f70118a50.zip FreeBSD-src-b6bdb6d2f3ebdde975a369669792021f70118a50.tar.gz |
Avoid signed overflow in error handling code.
Reviewed by: cperciva, bjk
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/split/split.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c index 561113e..572af59 100644 --- a/usr.bin/split/split.c +++ b/usr.bin/split/split.c @@ -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"); |