Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check RPL Target prefix length and buffer boundary. #1615

Merged
merged 1 commit into from Sep 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Check RPL Target prefix length and buffer boundary.
  • Loading branch information
nvt committed Sep 24, 2021
commit 587ae59956e00316fd44fd7072ac3a6a07b4b20f
26 changes: 26 additions & 0 deletions os/net/routing/rpl-classic/rpl-icmp6.c
Expand Up @@ -744,6 +744,19 @@ dao_input_storing(void)
case RPL_OPTION_TARGET:
/* Handle the target option. */
prefixlen = buffer[i + 3];
if(prefixlen == 0) {
/* Ignore option targets with a prefix length of 0. */
break;
}
if(prefixlen > 128) {
LOG_ERR("Too large target prefix length %d\n", prefixlen);
return;
}
if(i + 4 + ((prefixlen + 7) / CHAR_BIT) > buffer_length) {
LOG_ERR("Insufficient space to copy RPL Target of %d bits\n",
prefixlen);
return;
}
memset(&prefix, 0, sizeof(prefix));
memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT);
break;
Expand Down Expand Up @@ -981,6 +994,19 @@ dao_input_nonstoring(void)
case RPL_OPTION_TARGET:
/* Handle the target option. */
prefixlen = buffer[i + 3];
if(prefixlen == 0) {
/* Ignore option targets with a prefix length of 0. */
break;
}
if(prefixlen > 128) {
LOG_ERR("Too large target prefix length %d\n", prefixlen);
return;
}
if(i + 4 + ((prefixlen + 7) / CHAR_BIT) > buffer_length) {
LOG_ERR("Insufficient space to copy RPL Target of %d bits\n",
prefixlen);
return;
}
memset(&prefix, 0, sizeof(prefix));
memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT);
break;
Expand Down