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

Ensure safety of ctz_debruijn implementation. #1194

Merged

Commits on Jan 17, 2023

  1. Ensure safety of ctz_debruijn implementation.

    Adding U to the magic constants ensures that we are not mixing unsigned and signed value during multiplication, and ensures that the multiplication will not be subject to integer promotion.
    
    The (uint32_t)/(uint64_t) casts ensure the values are properly truncated no matter the size of an int.
    
    Prior to this commit, if secp256k1_ctz32_var_debruijn were some how managed to be built on a platform with 64-bit ints, (though this function is specifically only intended to be used on 32-bit platforms) it would perform an out-of-bounds array access.
    roconnor-blockstream committed Jan 17, 2023
    Configuration menu
    Copy the full SHA
    d6ff738 View commit details
    Browse the repository at this point in the history