sodium_compare(): cast operands to unsigned int
This matches the Zig implementation and fixes #1184
This commit is contained in:
parent
17d9198774
commit
3f3d350387
@ -242,8 +242,8 @@ sodium_compare(const unsigned char *b1_, const unsigned char *b2_, size_t len)
|
|||||||
i--;
|
i--;
|
||||||
x1 = b1[i];
|
x1 = b1[i];
|
||||||
x2 = b2[i];
|
x2 = b2[i];
|
||||||
gt |= ((x2 - x1) >> 8) & eq;
|
gt |= (((unsigned int) x2 - (unsigned int) x1) >> 8) & eq;
|
||||||
eq &= ((x2 ^ x1) - 1) >> 8;
|
eq &= (((unsigned int) (x2 ^ x1)) - 1) >> 8;
|
||||||
}
|
}
|
||||||
return (int) (gt + gt + eq) - 1;
|
return (int) (gt + gt + eq) - 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user