Skip to content

net/sixlowpan: Check if g_frame_hdrlen + IPv6_HDRLEN <= iob->io_len#18857

Open
acassis wants to merge 2 commits into
apache:masterfrom
acassis:fix_net_6lowpan_again
Open

net/sixlowpan: Check if g_frame_hdrlen + IPv6_HDRLEN <= iob->io_len#18857
acassis wants to merge 2 commits into
apache:masterfrom
acassis:fix_net_6lowpan_again

Conversation

@acassis
Copy link
Copy Markdown
Contributor

@acassis acassis commented May 8, 2026

Summary

Fix another issue where g_frame_hdrlen is not checked correctly

Impact

Improvement

Testing

$ ./tools/configure.sh b-l475e-iot01a:spirit-6lowpan

@github-actions github-actions Bot added Area: Networking Effects networking subsystem Size: S The size of the change in this PR is small labels May 8, 2026
This commit checks if the incoming 6LoWPAN frame header len + the
IPv6_HDRLEN will fit inside the b->io_len.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
@acassis acassis force-pushed the fix_net_6lowpan_again branch from b2c58db to 10cfc96 Compare May 8, 2026 15:42
Copy link
Copy Markdown
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

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

Thank you @acassis :-)

@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented May 8, 2026

@cederom endofframe is where the received data ends, so the test verifies if this position is lesser than the header len. It is confuse to understand if you don't spend some time looking the code

There was another small issue on sixlowpan_input.c code, it was
processing protosize and 8-bit instead of 16-bit.

It was working because the max tcp->tcpoffset was 0xf0, so
protosize = ((uint16_t)tcp->tcpoffset >> 4) << 2;
Will be protosize = 15 * 4 = 60 and will fit inside 8-bit.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
@acassis acassis force-pushed the fix_net_6lowpan_again branch from 10cfc96 to 2f58087 Compare May 8, 2026 19:02
g_uncomp_hdrlen += protosize;
return protosize;

return (int)protosize;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why need the cast

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, uint16_it is automatically promoted to int.

goto errout_with_reass;
}

protosize = (uint8_t) ret;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove space before ret


static uint16_t sixlowpan_uncompress_ipv6proto(FAR uint8_t *fptr,
FAR uint8_t *bptr)
static int sixlowpan_uncompress_ipv6proto(FAR struct iob_s *iob,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's return result through FAR uint16_t *?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you mean pass protosize as parameter (FAR uint16_t *) and keep int return?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes.

@lupyuen
Copy link
Copy Markdown
Member

lupyuen commented May 10, 2026

Hi: Could you Rebase your PR with the Master Branch? We fixed the Config Error for esp32p4-function-ev-board. Thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Networking Effects networking subsystem Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants