mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2026-02-05 18:20:32 +03:00
Fix undefined behavior of left shift
Left shifting UCHAR promotes it to a signed integer. When the value is >= 128 and shifted by 24, the result sets the sign bit, causing undefined behavior. Fixes it by explicit casting to UINT.
This commit is contained in:
@ -4761,7 +4761,7 @@ static void MY_SHA0_Transform(MY_SHA0_CTX* ctx) {
|
|||||||
UCHAR* p = ctx->buf;
|
UCHAR* p = ctx->buf;
|
||||||
int t;
|
int t;
|
||||||
for(t = 0; t < 16; ++t) {
|
for(t = 0; t < 16; ++t) {
|
||||||
UINT tmp = *p++ << 24;
|
UINT tmp = (UINT)*p++ << 24;
|
||||||
tmp |= *p++ << 16;
|
tmp |= *p++ << 16;
|
||||||
tmp |= *p++ << 8;
|
tmp |= *p++ << 8;
|
||||||
tmp |= *p++;
|
tmp |= *p++;
|
||||||
|
|||||||
Reference in New Issue
Block a user