mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/shell/ping: add protection from icmp packet overflow
This commit is contained in:
parent
d7000477d4
commit
be7ae57891
@ -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++) {
|
||||
@ -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) || ((unsigned)value > (UINT16_MAX - sizeof(icmpv6_hdr_t)))) {
|
||||
printf("ICMPv6 datagram size should be in range 0-65527.\n");
|
||||
return -1;
|
||||
}
|
||||
data->datalen = value;
|
||||
continue;
|
||||
}
|
||||
/* intentionally falls through */
|
||||
|
Loading…
Reference in New Issue
Block a user