diff --git a/Userland/Utilities/ping.cpp b/Userland/Utilities/ping.cpp index 825608112d..4f9ecea2d6 100644 --- a/Userland/Utilities/ping.cpp +++ b/Userland/Utilities/ping.cpp @@ -24,9 +24,9 @@ #include #include -static int total_pings; +static uint32_t total_pings; static int successful_pings; -static int count; +static uint32_t count; static uint32_t total_ms; static int min_ms; static int max_ms; @@ -67,6 +67,11 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_option(payload_size, "Amount of bytes to send as payload in the ECHO_REQUEST packets.", "size", 's', "size"); args_parser.parse(arguments); + if (count < 1 || count > UINT32_MAX) { + warnln("invalid count argument: '{}': out of range: 1 <= value <= {}", count, UINT32_MAX); + return 1; + } + if (payload_size < 0) { // Use the default. payload_size = 32 - sizeof(struct icmphdr);