Skip to content

Commit 10b6105

Browse files
authored
Merge pull request #6424 from SparkiDev/coverity_2
Coverity scan fixes
2 parents 7e3aafb + 2c34210 commit 10b6105

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6146,6 +6146,7 @@ enum {
61466146
* @param [out] hash Hash algorithm to use on message.
61476147
* @param [out] mgf MGF algorithm to use with PSS padding.
61486148
* @param [out] saltLen Length of salt in PSS padding.
6149+
* @return BAD_FUNC_ARG when the params is NULL.
61496150
* @return ASN_PARSE_E when the decoding fails.
61506151
* @return 0 on success.
61516152
*/
@@ -6160,7 +6161,10 @@ static int DecodeRsaPssParams(const byte* params, word32 sz,
61606161
byte tag;
61616162
int length;
61626163

6163-
if (GetSequence_ex(params, &idx, &len, sz, 1) < 0) {
6164+
if (params == NULL) {
6165+
ret = BAD_FUNC_ARG;
6166+
}
6167+
if ((ret == 0) && (GetSequence_ex(params, &idx, &len, sz, 1) < 0)) {
61646168
ret = ASN_PARSE_E;
61656169
}
61666170
if (ret == 0) {
@@ -6252,6 +6256,10 @@ static int DecodeRsaPssParams(const byte* params, word32 sz,
62526256
int ret = 0;
62536257
word16 sLen = 20;
62546258

6259+
if (params == NULL) {
6260+
ret = BAD_FUNC_ARG;
6261+
}
6262+
62556263
CALLOC_ASNGETDATA(dataASN, rsaPssParamsASN_Length, ret, NULL);
62566264
if (ret == 0) {
62576265
word32 inOutIdx = 0;
@@ -37243,8 +37251,11 @@ static void PrintObjectIdText(Asn1* asn1, Asn1PrintOptions* opts)
3724337251
int known = 1;
3724437252

3724537253
/* Get the OID value for the OBJECT_ID. */
37246-
GetObjectId(asn1->data + asn1->offset, &i, &oid, oidIgnoreType,
37247-
asn1->item.len + 2);
37254+
if (GetObjectId(asn1->data + asn1->offset, &i, &oid, oidIgnoreType,
37255+
asn1->item.len + 2) == ASN_PARSE_E) {
37256+
known = 0;
37257+
}
37258+
else
3724837259
#if !defined(WOLFCRYPT_ONLY) && defined(OPENSSL_EXTRA)
3724937260
/* Lookup NID for OID value. */
3725037261
if ((nid = oid2nid(oid, oidIgnoreType)) != -1) {

0 commit comments

Comments
 (0)