fix for scan build warning and better check on size

This commit is contained in:
Jacob Barthelmeh
2021-09-13 09:35:55 -06:00
parent 602ec188ad
commit f06414903c

View File

@@ -26821,14 +26821,14 @@ static int DecodeAsymKey(const byte* input, word32* inOutIdx, word32 inSz,
if (GetOctetString(input, inOutIdx, &privSz, inSz) < 0)
return ASN_PARSE_E;
if ((word32)privSz > *privKeyLen)
return BUFFER_E;
priv = input + *inOutIdx;
*inOutIdx += privSz;
endKeyIdx = *inOutIdx;
}
if ((word32)privSz > *privKeyLen)
return BUFFER_E;
if (endKeyIdx == (int)*inOutIdx) {
*privKeyLen = privSz;
XMEMCPY(privKey, priv, *privKeyLen);
@@ -26836,6 +26836,10 @@ static int DecodeAsymKey(const byte* input, word32* inOutIdx, word32 inSz,
*pubKeyLen = 0;
}
else {
if (pubKeyLen == NULL) {
return BAD_FUNC_ARG;
}
if (GetASNHeader(input, ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | 1,
inOutIdx, &length, inSz) < 0) {
return ASN_PARSE_E;