From 0f36cbbfbb33554482f86b90bbe673c9c4f917a3 Mon Sep 17 00:00:00 2001 From: miod <> Date: Thu, 16 Jul 2015 02:18:58 +0000 Subject: Explicitely cast a char into unsigned long before shifting it left by 24, for this would promote it to int for the shift, and then cast to unsigned long, sign-extending it if sizeof(long) > sizeof(int). This was not a problem because the computed value was explicitely range checked afterwards, with an upper bound way smaller than 1U<<31, but it's better practice to cast correctly. ok beck@ --- src/lib/libcrypto/asn1/a_mbstr.c | 4 ++-- src/lib/libssl/src/crypto/asn1/a_mbstr.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/asn1/a_mbstr.c b/src/lib/libcrypto/asn1/a_mbstr.c index 9ce0a000fe..e715fe7348 100644 --- a/src/lib/libcrypto/asn1/a_mbstr.c +++ b/src/lib/libcrypto/asn1/a_mbstr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_mbstr.c,v 1.21 2014/10/12 20:47:12 miod Exp $ */ +/* $OpenBSD: a_mbstr.c,v 1.22 2015/07/16 02:18:58 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -288,7 +288,7 @@ traverse_string(const unsigned char *p, int len, int inform, len -= 2; break; case MBSTRING_UNIV: - value = *p++ << 24; + value = (unsigned long)*p++ << 24; value |= *p++ << 16; value |= *p++ << 8; value |= *p++; diff --git a/src/lib/libssl/src/crypto/asn1/a_mbstr.c b/src/lib/libssl/src/crypto/asn1/a_mbstr.c index 9ce0a000fe..e715fe7348 100644 --- a/src/lib/libssl/src/crypto/asn1/a_mbstr.c +++ b/src/lib/libssl/src/crypto/asn1/a_mbstr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_mbstr.c,v 1.21 2014/10/12 20:47:12 miod Exp $ */ +/* $OpenBSD: a_mbstr.c,v 1.22 2015/07/16 02:18:58 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -288,7 +288,7 @@ traverse_string(const unsigned char *p, int len, int inform, len -= 2; break; case MBSTRING_UNIV: - value = *p++ << 24; + value = (unsigned long)*p++ << 24; value |= *p++ << 16; value |= *p++ << 8; value |= *p++; -- cgit v1.2.3-55-g6feb