Skip to content

[Bug] CRITICAL - INCORRECT HASH CALCULATION #21844

@VbhvGupta

Description

@VbhvGupta

unsigned char *p = (unsigned char *) v1;
while (*p++)
hash = (hash << 5) - (hash + *p);

The *p++ increment happens before the hash calculation, so when *p is referenced inside the loop, Its actually looking at the character after the one that was just tested.

This means:

  • The first character of the string is never hashed
  • We are hashing one character past where we should be (potentially garbage memory after the null terminator)

Any two UTF‑8 strings that only differ in their initial character (e.g., "abc" vs. "xbc") will therefore produce identical hash values and single‑character strings hash to zero.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions