summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/fmt/fmt.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/usr.bin/fmt/fmt.c b/usr.bin/fmt/fmt.c
index 33f92b1..ed85c2e 100644
--- a/usr.bin/fmt/fmt.c
+++ b/usr.bin/fmt/fmt.c
@@ -176,6 +176,7 @@ static const char copyright[] =
__FBSDID("$FreeBSD$");
#include <err.h>
+#include <limits.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
@@ -351,6 +352,7 @@ main(int argc, char *argv[]) {
}
if (goal_length==0) goal_length = 65;
if (max_length==0) max_length = goal_length+10;
+ if (max_length >= SIZE_T_MAX / sizeof (wchar_t)) errx(EX_USAGE, "max length too large");
/* really needn't be longer */
output_buffer = XMALLOC((max_length+1) * sizeof(wchar_t));
OpenPOWER on IntegriCloud