Skip to content

Commit

Permalink
param dup: add errors to failure returns
Browse files Browse the repository at this point in the history
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from #17440)

(cherry picked from commit a10a576)
Reviewed-by: Hugo Landau <hlandau@openssl.org>
  • Loading branch information
paulidale authored and t8m committed Nov 9, 2022
1 parent 584e447 commit 4c4ac7c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crypto/params_dup.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ OSSL_PARAM *OSSL_PARAM_dup(const OSSL_PARAM *src)
OSSL_PARAM *last, *dst;
int param_count = 1; /* Include terminator in the count */

if (src == NULL)
if (src == NULL) {
ERR_raise(ERR_LIB_CRYPTO, ERR_R_PASSED_NULL_PARAMETER);
return NULL;
}

memset(buf, 0, sizeof(buf));

Expand Down Expand Up @@ -154,8 +156,10 @@ OSSL_PARAM *OSSL_PARAM_merge(const OSSL_PARAM *p1, const OSSL_PARAM *p2)
size_t list1_sz = 0, list2_sz = 0;
int diff;

if (p1 == NULL && p2 == NULL)
if (p1 == NULL && p2 == NULL) {
ERR_raise(ERR_LIB_CRYPTO, ERR_R_PASSED_NULL_PARAMETER);
return NULL;
}

/* Copy p1 to list1 */
if (p1 != NULL) {
Expand All @@ -170,8 +174,10 @@ OSSL_PARAM *OSSL_PARAM_merge(const OSSL_PARAM *p1, const OSSL_PARAM *p2)
list2[list2_sz++] = p;
}
list2[list2_sz] = NULL;
if (list1_sz == 0 && list2_sz == 0)
if (list1_sz == 0 && list2_sz == 0) {
ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_NO_PARAMS_TO_MERGE);
return NULL;
}

/* Sort the 2 lists */
qsort(list1, list1_sz, sizeof(OSSL_PARAM *), compare_params);
Expand Down

0 comments on commit 4c4ac7c

Please sign in to comment.