-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sha1sum.c, sha256.c: make code work with -fstrict-aliasing
-fstrict-aliasing is enabled by default when using optimization levels higher than 1, including -Os. With that option, compiler may assume that object of one type never resides at the same address as object of a different type. Both sha1_final() and sha256_final() used to write message length by casting a pointer to buffer into a pointer to u64, while surrounding code operated on the buffer directly. The problem manifests in GCC 11 (and possibly later versions). To solve this problem, the commit adds message length field to SHA context structures and accesses it through the structure, without any casting to different types. Message length is declared volatile, otherwise compiler doesn't write it before address of buffer is obtained and passed to sha*_transform(). Signed-off-by: Krystian Hebel <[email protected]>
- Loading branch information
1 parent
87833a0
commit 9db046c
Showing
2 changed files
with
42 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters