diff --git a/usr.bin/fmt/fmt.c b/usr.bin/fmt/fmt.c index 33f92b1b82d5..ed85c2e49f2a 100644 --- a/usr.bin/fmt/fmt.c +++ b/usr.bin/fmt/fmt.c @@ -176,6 +176,7 @@ static const char copyright[] = __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -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));