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 unaligned casting of cmsg data to af_alg_iv #1206

Merged
merged 1 commit into from
Apr 19, 2020

Conversation

glebpom
Copy link
Contributor

@glebpom glebpom commented Apr 7, 2020

Casting a pointer to cmsg_data to af_alg_iv is incorrect since it's not properly aligned. As of the cmsg man page "Applications should not cast it to a pointer type matching the payload, but should instead use memcpy(3) to copy data to or from a suitably declared object."

@glebpom glebpom changed the title Fix unaligned castting of cmsg data to af_alg_iv Fix unaligned casting of cmsg data to af_alg_iv Apr 7, 2020
@asomers
Copy link
Member

asomers commented Apr 8, 2020

Thanks for the fix. Might I ask how you found the problem? Also, could you please add a CHANGELOG entry?

@glebpom
Copy link
Contributor Author

glebpom commented Apr 8, 2020

Sure, that was pretty easy with clippy. BTW, few other things are treated as errors by clippy as well. It would make sense to add clippy check as a CI step.

@glebpom glebpom force-pushed the af-alg-unaligned-access-fix branch from 1879eef to 75ca048 Compare April 8, 2020 07:22
@glebpom glebpom force-pushed the af-alg-unaligned-access-fix branch from 75ca048 to 0a99945 Compare April 8, 2020 14:11
Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

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

bors r+

bors bot added a commit that referenced this pull request Apr 14, 2020
1206: Fix unaligned casting of cmsg data to af_alg_iv r=asomers a=glebpom

Casting a pointer to `cmsg_data` to `af_alg_iv` is incorrect since it's not properly aligned. As of the [`cmsg` man page](http://man7.org/linux/man-pages/man3/cmsg.3.html) "Applications should not cast it to a pointer type matching the payload, but should instead use memcpy(3) to copy data to or from a suitably declared object." 

Co-authored-by: Gleb Pomykalov <gleb@lancastr.com>
@bors
Copy link
Contributor

bors bot commented Apr 14, 2020

Build failed:

@asomers
Copy link
Member

asomers commented Apr 19, 2020

bors retry

@bors
Copy link
Contributor

bors bot commented Apr 19, 2020

Build succeeded:

@bors bors bot merged commit fdf828b into nix-rust:master Apr 19, 2020
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