Skip to content

Commit

Permalink
sys/shell/ping: add protection from icmp packet overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztof-cabaj committed Sep 16, 2023
1 parent ee081d1 commit e0c4ebf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sys/shell/cmds/gnrc_icmpv6_echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ static int _configure(int argc, char **argv, _ping_data_t *data)
{
char *cmdname = argv[0];
int res = 1;
int value;

/* parse command line arguments */
for (int i = 1; i < argc; i++) {
Expand Down Expand Up @@ -207,7 +208,13 @@ static int _configure(int argc, char **argv, _ping_data_t *data)
/* intentionally falls through */
case 's':
if ((++i) < argc) {
data->datalen = atoi(argv[i]);
value = atoi(argv[i]);

if(value < 0 || value > 65527) {

Check warning on line 213 in sys/shell/cmds/gnrc_icmpv6_echo.c

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'if' not followed by a single space
printf("ICMPv6 datagram size should be in range <0, 65527>.\n");
return -1;
}
data->datalen = value;
continue;
}
/* intentionally falls through */
Expand Down

0 comments on commit e0c4ebf

Please sign in to comment.