Parcourir la source

signal a potential overflow when decoding a `LTC_ASN1_SHORT_INTEGER`

Signed-off-by: Steffen Jaeckel <[email protected]>
Steffen Jaeckel il y a 3 ans
Parent
commit
3bf3dffabc
1 fichiers modifiés avec 4 ajouts et 0 suppressions
  1. 4 0
      src/pk/asn1/der/short_integer/der_decode_short_integer.c

+ 4 - 0
src/pk/asn1/der/short_integer/der_decode_short_integer.c

@@ -42,6 +42,10 @@ int der_decode_short_integer(const unsigned char *in, unsigned long inlen, unsig
       return CRYPT_INVALID_PACKET;
    }
 
+   if (len > sizeof(unsigned long)) {
+      return CRYPT_OVERFLOW;
+   }
+
    /* read number */
    y = 0;
    while (len--) {