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

community-id: Fix IPv6 address sorting not respecting byte order #9399

Conversation

awelzel
Copy link
Contributor

@awelzel awelzel commented Aug 20, 2023

Make sure these boxes are signed before submitting your Pull Request -- thank you.

Link to redmine ticket:
https://redmine.openinfosecfoundation.org/issues/6276

Describe changes:
When comparing IPv6 addresses based on uint32_t chunks, one needs to apply ntohl() conversion to the individual parts, otherwise on little endian systems individual bytes are compared in the wrong order. Avoid this all and leverage memcmp(), it'll short circuit on the first differing byte and its return values tells us which address sorts lower.

Provide values to any of the below to override the defaults.

To use a pull request use a branch name like pr/N where N is the
pull request number.

Alternatively, SV_BRANCH may also be a link to an
OISF/suricata-verify pull-request.

SV_REPO=
SV_BRANCH=https://github.com/OISF/suricata-verify/pull/1360
SU_REPO=
SU_BRANCH=
LIBHTP_REPO=
LIBHTP_BRANCH=

When comparing IPv6 addresses based on uint32_t chunks, one needs to
apply ntohl() conversion to the individual parts, otherwise on little
endian systems individual bytes are compared in the wrong order.
Avoid this all and leverage memcmp(), it'll short circuit on the first
differing byte and its return values tells us which address sorts lower.
@awelzel awelzel requested a review from victorjulien as a code owner August 20, 2023 15:57
@codecov
Copy link

codecov bot commented Aug 20, 2023

Codecov Report

Merging #9399 (752392a) into master (becb8ce) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9399      +/-   ##
==========================================
- Coverage   82.17%   82.16%   -0.02%     
==========================================
  Files         968      968              
  Lines      274198   274190       -8     
==========================================
- Hits       225331   225285      -46     
- Misses      48867    48905      +38     
Flag Coverage Δ
fuzzcorpus 64.04% <0.00%> (+<0.01%) ⬆️
suricata-verify 60.91% <100.00%> (+0.03%) ⬆️
unittests 62.88% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@jasonish
Copy link
Member

Suricata-Verify tests added here: OISF/suricata-verify#1360

Re-running CI to pick up SV PR.

Copy link
Contributor

@catenacyber catenacyber left a comment

Choose a reason for hiding this comment

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

Thanks for this fix

Could you just reword the commit to include the redmine ticket reference ?
cf https://docs.suricata.io/en/latest/devguide/codebase/contributing/code-submission-process.html#commits

Here is my feedback :
CI : green
Code : looks good (negative number of lines :-) )
Commits segmentation : ok
Commit messages : Could you put the redmine ticket reference in the commit ?
Git ID set : looks fine for me
CLA : I do not have access, but you say to have signed it
Doc update : not needed
Redmine ticket : ok
Rustfmt : no rust
Tests : S-V looks ok
Dependencies added: none

@jasonish jasonish mentioned this pull request Aug 30, 2023
@jasonish
Copy link
Member

Commit messages : Could you put the redmine ticket reference in the commit ?

Already did in a staging branch.

@jasonish jasonish mentioned this pull request Aug 30, 2023
@victorjulien
Copy link
Member

Commit messages : Could you put the redmine ticket reference in the commit ?

Already did in a staging branch.

@jasonish Can you make sure the updated commit is not lost now that the staging branch is closed?

@catenacyber
Copy link
Contributor

Done in #9442

@catenacyber catenacyber closed this Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants