diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c index 628e71439e3e..0239fee4e12d 100644 --- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c +++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c @@ -1056,7 +1056,7 @@ X509GetSerialNumber ( } if (SerialNumber != NULL) { - CopyMem (SerialNumber, Asn1Integer->data, *SerialNumberSize); + CopyMem (SerialNumber, Asn1Integer->data, (UINTN)Asn1Integer->length); Status = TRUE; }