Skip to content
Open
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/lmic/lmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ static CONST_TABLE(u1_t, macCmdSize)[] = {
static u1_t getMacCmdSize(u1_t macCmd) {
if (macCmd < 2)
return 0;
if (macCmd >= LENOF_TABLE(macCmdSize) - 2)
if ((macCmd - 2) >= LENOF_TABLE(macCmdSize))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh. Sorry about this one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, but I'm wondering why 0 is returned in the error case, because in scan_mac_cmds I see no check except for line 887, which doesn't do what the comment says.

https://github.com/sualko/arduino-lmic/blob/cabf6fbcd4390fcc42102a47c0323b7dafc6723a/src/lmic/lmic.c#L887

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a bug too -- no test cases for bad mac commands, even in certification.

Should be if (cmdlen == 0 || cmdlen >> olen - oidx).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was fixed in 06b53c7, merged in #555 (and possibly before that, but that's the most recent change).

return 0;
return TABLE_GET_U1(macCmdSize, macCmd - 2);
}
Expand Down