From: Tomas Mraz Date: Tue, 19 May 2020 08:51:19 +0000 (+0200) Subject: Cast the unsigned char to unsigned int before shifting left X-Git-Tag: openssl-3.0.0-alpha3~70 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=cbeb0bfa961412eebfbdf1e72900f05527e81e15;ds=sidebyside Cast the unsigned char to unsigned int before shifting left This is needed to avoid automatic promotion to signed int. Fixes #11853 [extended tests] Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/11857) --- diff --git a/crypto/pem/pvkfmt.c b/crypto/pem/pvkfmt.c index e2f5702880..6d85a8a4e1 100644 --- a/crypto/pem/pvkfmt.c +++ b/crypto/pem/pvkfmt.c @@ -36,10 +36,10 @@ static unsigned int read_ledword(const unsigned char **in) { const unsigned char *p = *in; unsigned int ret; - ret = *p++; - ret |= (*p++ << 8); - ret |= (*p++ << 16); - ret |= (*p++ << 24); + ret = (unsigned int)*p++; + ret |= (unsigned int)*p++ << 8; + ret |= (unsigned int)*p++ << 16; + ret |= (unsigned int)*p++ << 24; *in = p; return ret; }