Skip to content

Conversation

paperino1983
Copy link

in function uint64_t hashmap_sip(const void *data, size_t len, uint64_t seed0,uint64_t seed1) wher the input buffer is smaller than 8 bytes, copy it into a zero-padded local buffer to avoid out-of-bounds reads

@tidwall
Copy link
Owner

tidwall commented Sep 9, 2025

The SIP64 function takes care of small (<8 bytes) buffers.

The function starts by looking for the end of the last known 8-byte segment.

    const uint8_t *end = in + inlen - (inlen % sizeof(uint64_t));
    for (; in != end; in += 8) {

@tidwall
Copy link
Owner

tidwall commented Sep 9, 2025

If the end equals in then that means the input is smaller than 8 bytes, and the function will only work on the single remaining bytes, one-by-one.

As far as I can tell it never reads past the end of the buffer.

@paperino1983
Copy link
Author

If the end equals in then that means the input is smaller than 8 bytes, and the function will only work on the single remaining bytes, one-by-one.

As far as I can tell it never reads past the end of the buffer.

Hi Tidwall, my bad I think you're right ! Thanks for your prompt reveview

@tidwall
Copy link
Owner

tidwall commented Sep 10, 2025

No problem. :)

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