ping(8): Check for integer truncation when handling the value for -s.

PR:		239976
Submitted by:	Neeraj <neerajpal09@gmail.com>
MFC after:	1 week
Event:		July 2020 Bugathon
This commit is contained in:
Mark Johnston 2020-07-11 17:10:16 +00:00
parent 5b8d2467eb
commit 87f9c14ad3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=363102

View File

@ -478,7 +478,7 @@ main(int argc, char *const *argv)
break;
case 's': /* size of packet to send */
ltmp = strtol(optarg, &ep, 0);
if (*ep || ep == optarg || ltmp < 0)
if (*ep || ep == optarg || ltmp > INT_MAX || ltmp < 0)
errx(EX_USAGE, "invalid packet size: `%s'",
optarg);
if (uid != 0 && ltmp > DEFDATALEN) {