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

Fix MPLS header parsing in ndpiReader. #506

Merged
merged 1 commit into from
Jan 9, 2018
Merged

Fix MPLS header parsing in ndpiReader. #506

merged 1 commit into from
Jan 9, 2018

Conversation

cavedon
Copy link
Contributor

@cavedon cavedon commented Jan 9, 2018

Reported at https://bugs.debian.org/886133.
The current parsing for the MPLS header in examples/ndpi_util.c has
multiple issues:

  • the bitfield order is incorrect for little endian architectures
  • ntohl() is applied to a 20 bit label, which has unclear purpose
  • if multiple labels are detected, the while loop parsing labels will
    never exit due to a missing re-read of the mpls label
  • the last label is identified by looking inside the label field, while
    it should be done by looking at the S bit

This change fixes the above issues.
Notice that bitfield ordering is implementation-dependent, so C
bitfields should not be used in the first place to parse network
packets.

Reported at https://bugs.debian.org/886133.
The current parsing for the MPLS header in examples/ndpi_util.c has
multiple issues:
- the bitfield order is incorrect for little endian architectures
- ntohl() is applied to a 20 bit label, which has unclear purpose
- if multiple labels are detected, the while loop parsing labels will
never exit due to a missing re-read of the mpls label
- the last label is identified by looking inside the label field, while
it should be done by looking at the S bit

This change fixes the above issues.
Notice that bitfield ordering is implementation-dependent, so C
bitfields should not be used in the first place to parse network
packets.
@kYroL01 kYroL01 merged commit 77cb8cc into ntop:dev Jan 9, 2018
@kYroL01
Copy link
Contributor

kYroL01 commented Jan 9, 2018

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants