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

[FLOSS H3] fix hashing collisions in specification token #4180

Merged
merged 1 commit into from Dec 16, 2021

Conversation

lawli3t
Copy link
Contributor

@lawli3t lawli3t commented Nov 23, 2021

Basics

These points need to be fulfilled for every PR:

  • Short descriptions of your changes are in the release notes
    (added as entry in doc/news/_preparation_next_release.md which
    contains _(my name)_)
    Please always add something to the release notes.
  • Details of what you changed are in commit messages
    (first line should have module: short statement syntax)
  • References to issues, e.g. close #X, are in the commit messages.
  • The buildservers are happy. If not, fix in this order:
    • add a line in doc/news/_preparation_next_release.md
    • reformat the code with scripts/dev/reformat-all
    • make all unit tests pass
    • fix all memleaks
  • The PR is rebased with current master.

If you have any troubles fulfilling these criteria, please write
about the trouble as comment in the PR. We will help you.
But we cannot accept PRs that do not fulfill the basics.

Checklist

Check relevant points but please do not remove entries.
For docu fixes, spell checking, and similar none of these points below
need to be checked.

  • I added unit tests for my code
  • I fully described what my PR does in the documentation
    (not in the PR description)
  • I fixed all affected documentation
  • I added code comments, logging, and assertions as appropriate (see Coding Guidelines)
  • I updated all meta data (e.g. README.md of plugins and METADATA.ini)
  • I mentioned every code not directly written by me in THIRD-PARTY-LICENSES

Review

Reviewers will usually check the following:

Labels

If you are already Elektra developer:

  • Add the "work in progress" label if you do not want the PR to be reviewed yet.
  • Add the "ready to merge" label if the basics are fulfilled and you also
    say that everything is ready to be merged.

@lawli3t lawli3t added bug work in progress cm2022s for university course labels Nov 23, 2021
@lawli3t lawli3t self-assigned this Nov 23, 2021
@lawli3t lawli3t changed the title [FLOSS H3] fix hashing collisions in streaming token [FLOSS H3] fix hashing collisions in specification token Nov 23, 2021
@lawli3t lawli3t added needs review please review this PR and removed work in progress labels Nov 24, 2021
@flo91 flo91 self-requested a review November 26, 2021 21:38
Copy link
Collaborator

@flo91 flo91 left a comment

Choose a reason for hiding this comment

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

[FLOSS H3]

Thanks for your PR, that looks like a really great improvement!

If I execute the testsuite tests/ctest/test_sha-256.c, which contains the test test_streaming_aware_of_order and is already present in current master, in the codebase of the master branch, it executes successfully.

I copied the test from issue #4110 as it is and it also succeeds with the Elektra version from the current master branch.

However, when I tried to execute your newly added test test_hashesMetadata in the testsuite tests/ctest/test_hash.c, it failed.
When I ran the new test on the codebase of your PR-branch, it succeeded, as already suggested by the passed buildserver checks.

I think to state that the PR close the issues #4110 (comment in line 85 of src/libs/ease/hash.c) can be misleading because the test that is mentioned in the description of that issue is already succeeding in the current master.

Maybe it would be better to create a new issue and link to it from the issue #4110 or at least post an update to the existing issue.
I don't know if the inclusion of the \0 for calculating the hash value breaks any other things, but at least all tests in Docker and on the buildservers ran successfully, so that looks quite good.

Regarding the commits, it would be good to combine ("squash") the three "fix formatting" commits to one commit and add a module-prefix like written in the PR-description.

Details of what you changed are in commit messages
(first line should have module: short statement syntax)

A rebase with the current master branch is also necessary.

sha_256_write (&sha_256, keyName (currentKey), keyGetNameSize (currentKey) - 1);
/**
* Include NULL teminator in this and all following key/value strings, to avoid the following bug:
* https://github.com/ElektraInitiative/libelektra/issues/4110
Copy link
Collaborator

@flo91 flo91 Nov 27, 2021

Choose a reason for hiding this comment

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

The reference to the issue #4110 could be misleading because the testcase that's in the description of the issue already succeeds in current master and your PR adds another test case.

@flo91 flo91 removed the needs review please review this PR label Nov 27, 2021
@lawli3t
Copy link
Contributor Author

lawli3t commented Dec 1, 2021

I copied the test from issue #4110 as it is and it also succeeds with the Elektra version from the current master branch.

I think this is because there is an error in the test. The test should check for inequality, not equality in the line:

succeed_if (strcmp(string1, string2) == 0, "streaming API of sha_256 is not aware of order!");

I'll check this out when I am a bit less tired and edit the test if applicable.

…minators

Fixes ElektraInitiative#4110

Added tests to detect this issue as well as changed existing tests so
they with the newly generated hashes
@lawli3t
Copy link
Contributor Author

lawli3t commented Dec 1, 2021

squashed and rebased

@markus2330
Copy link
Contributor

@lawli3t Elegant solution!

@flo91 Excellent review except I wouldn't push users into squashing commits. It is their decision.

@markus2330 markus2330 added the 7p seven points label Dec 13, 2021
@markus2330
Copy link
Contributor

LGTM. Please add the label "ready to merge" if it is ready to merge.

@markus2330 markus2330 merged commit b196fd0 into ElektraInitiative:master Dec 16, 2021
@markus2330
Copy link
Contributor

Excellent job! 🎆

@mpranj mpranj added this to the 0.9.9 milestone Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7p seven points bug cm2022s for university course ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants