aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/split/split.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/split/split.c')
-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");