Skip to content

Avoid undefined behavior in Windows ftok(3) emulation #9958

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

Closed
wants to merge 1 commit into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Nov 15, 2022

.nFileIndexHigh is a unsigned 32bit number. Casting that to __int64 and shifting left by 32bits triggers undefined behavior if the most significant bit of .nFileIndexHigh is set. We could avoid that by casting to (__uint64), but in that case the whole clause doesn't have an effect anymore, so we drop it altogether.

`.nFileIndexHigh` is a unsigned 32bit number.  Casting that to `__int64`
and shifting left by 32bits triggers undefined behavior if the most
significant bit of `.nFileIndexHigh` is set.  We could avoid that by
casting to `(__uint64)`, but in that case the whole clause doesn't have
an effect anymore, so we drop it altogether.
@cmb69 cmb69 closed this in 2d94ee5 Nov 18, 2022
@cmb69 cmb69 deleted the cmb/ftok branch November 18, 2022 13:40
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.

1 participant