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

bug in function Sha1Digest_fromStr #1

Open
windyuuy opened this issue Feb 28, 2017 · 0 comments
Open

bug in function Sha1Digest_fromStr #1

windyuuy opened this issue Feb 28, 2017 · 0 comments

Comments

@windyuuy
Copy link

assert(src); // also, src must be at least 40 bytes
for (i = 0; i < 20 && src[i]; i++)
{
    // \todo just use atoi or something
    int c0 = tolower(*src++);
    int c1 = tolower(*src++);

    c0 = '0' <= c0 && c0 <= '9' ? c0 - '0' : ('a' <= c0 && c0 <= 'f' ? 0xa + c0 - 'a' : -1);
    c1 = '0' <= c1 && c1 <= '9' ? c1 - '0' : ('a' <= c1 && c1 <= 'f' ? 0xa + c1 - 'a' : -1);
    ((uint8_t*)d.digest)[i] = (uint8_t)((c0 << 4) | c1);
}

there "src[i]" seems conflict with "*sc++"

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