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

ByteParser.bytesToUint64: require check too early #12

Open
gsalzer opened this issue Feb 25, 2025 · 0 comments
Open

ByteParser.bytesToUint64: require check too early #12

gsalzer opened this issue Feb 25, 2025 · 0 comments

Comments

@gsalzer
Copy link

gsalzer commented Feb 25, 2025

The require check in ByteParser.bytesToUint64 happens too early: The return value of the function that is only computed in the next row, is already checked when entering the function. As new variables seem to be initialized to zero, the check always succeeds, but misses its purpose.

    function bytesToUint64(bytes memory data) public pure returns (uint64 value) {
        require(value <= MAX_UINT64, "Number too large! Use `bytesToBigNumber` instead!");
        value = uint64(bytesToBigNumber(data));
    }

Fix: Move the require statement below the assignment.

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

No branches or pull requests

1 participant