]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
bn_lib.c: Change Endianess check to as a binary condition.
authorKelvin Lee <kiyolee@gmail.com>
Sat, 22 Jan 2022 00:22:31 +0000 (11:22 +1100)
committerTomas Mraz <tomas@openssl.org>
Thu, 10 Feb 2022 14:20:30 +0000 (15:20 +0100)
This prevents VS2022 from mis-identify an uninitialized local pointer
variable.

CLA: trivial

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17567)

crypto/bn/bn_lib.c

index b49c8a3bd27b0e157df4e8444398366ebda0fe79..05b36033a5fa25c860abfbc71fad0259633d013e 100644 (file)
@@ -455,18 +455,15 @@ static BIGNUM *bin2bn(const unsigned char *s, int len, BIGNUM *ret,
      * significant BIGNUM chunk, so we adapt parameters to transfer
      * input bytes accordingly.
      */
-    switch (endianess) {
-    case LITTLE:
+    if (endianess == LITTLE) {
         s2 = s + len - 1;
         inc2 = -1;
         inc = 1;
-        break;
-    case BIG:
+    } else {
         s2 = s;
         inc2 = 1;
         inc = -1;
         s += len - 1;
-        break;
     }
 
     /* Take note of the signedness of the input bytes*/
@@ -593,14 +590,11 @@ static int bn2binpad(const BIGNUM *a, unsigned char *to, int tolen,
      * to most significant BIGNUM limb, so we adapt parameters to
      * transfer output bytes accordingly.
      */
-    switch (endianess) {
-    case LITTLE:
+    if (endianess == LITTLE) {
         inc = 1;
-        break;
-    case BIG:
+    } else {
         inc = -1;
         to += tolen - 1;         /* Move to the last byte, not beyond */
-        break;
     }
 
     lasti = atop - 1;