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

gnrc_lorawan: Ensure minimal packet length #20880

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sys/net/gnrc/link_layer/lorawan/gnrc_lorawan_mcps.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ int gnrc_lorawan_parse_dl(gnrc_lorawan_t *mac, uint8_t *buf, size_t len,
pkt->fopts.iol_base = buf;
pkt->fopts.iol_len = fopts_length;
buf += fopts_length;
if (buf >= p_mic) {
benpicco marked this conversation as resolved.
Show resolved Hide resolved
DEBUG("gnrc_lorawan: packet with fopts but no payload. Drop\n");
return -1;
}
}

if (buf < p_mic) {
Expand Down Expand Up @@ -165,6 +169,11 @@ void gnrc_lorawan_mcps_process_downlink(gnrc_lorawan_t *mac, uint8_t *psdu,
{
struct parsed_packet _pkt;

if (size < sizeof(lorawan_hdr_t) + MIC_SIZE) {
DEBUG("gnrc_lorawan: invalid psdu size\n");
return;
}

/* NOTE: MIC is in pkt */
if (!gnrc_lorawan_mic_is_valid(psdu, size, mac->ctx.snwksintkey,
mac->mcps.fcnt, gnrc_lorawan_optneg_is_set(mac))) {
Expand Down
Loading