aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2013-05-21 19:56:03 +0000
committerEitan Adler <eadler@FreeBSD.org>2013-05-21 19:56:03 +0000
commit89c5c3aab88d115a8d6b2839fc5d24265162a43e (patch)
treec79905058c16d5132529a8f144d5e329c11c7a65
parentab76bc977ad2cf5c4ea690f002fd7c049e14a768 (diff)
downloadsrc-89c5c3aab88d115a8d6b2839fc5d24265162a43e.tar.gz
src-89c5c3aab88d115a8d6b2839fc5d24265162a43e.zip
Avoid signed overflow in error handling code.
Reviewed by: cperciva, bjk
Notes
Notes: svn path=/head/; revision=250882
-rw-r--r--usr.bin/split/split.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c
index 561113e0bcc9..572af5993071 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");