Skip to content

fix UB in ComputeSHA-1#5957

Merged
raysan5 merged 1 commit into
raysan5:masterfrom
TheFissk:ub-computesha1
Jul 6, 2026
Merged

fix UB in ComputeSHA-1#5957
raysan5 merged 1 commit into
raysan5:masterfrom
TheFissk:ub-computesha1

Conversation

@TheFissk

@TheFissk TheFissk commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Fixes UB related to integer promotion in ComputeSHA1.

When compiling with UBSans on (like the zig compiler does) unsigned chars are promoted to integers, so any value in msg > 128 will cause the 32nd bit to be set and technically triggering a signed integer overflow. This shouldn't cause issues in most compilers but it is techincally UB. explicitly casing the msg to an unsigned int fixes the problem

the fastest way to replicate the above issue to run zig build core_compute_hash and press the compute input data hashes button

@raysan5 raysan5 merged commit 3d64069 into raysan5:master Jul 6, 2026
@raysan5

raysan5 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

@TheFissk Thanks for the review!

@TheFissk TheFissk deleted the ub-computesha1 branch July 6, 2026 16:47
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