Skip to content

Commit

Permalink
X509at_add1_attr*(): extend error entry on duplicate attribute
Browse files Browse the repository at this point in the history
Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from openssl#24792)
  • Loading branch information
DDvO authored and t8m committed Jul 10, 2024
1 parent 39424d9 commit 7760021
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crypto/x509/x509_att.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
return NULL;
}
if (*x != NULL && X509at_get_attr_by_OBJ(*x, attr->object, -1) != -1) {
ERR_raise(ERR_LIB_X509, X509_R_DUPLICATE_ATTRIBUTE);
ERR_raise_data(ERR_LIB_X509, X509_R_DUPLICATE_ATTRIBUTE,
"name=%s", OBJ_nid2sn(OBJ_obj2nid(attr->object)));
return NULL;
}

Expand Down Expand Up @@ -158,7 +159,8 @@ STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE)
return NULL;
}
if (*x != NULL && X509at_get_attr_by_OBJ(*x, obj, -1) != -1) {
ERR_raise(ERR_LIB_X509, X509_R_DUPLICATE_ATTRIBUTE);
ERR_raise_data(ERR_LIB_X509, X509_R_DUPLICATE_ATTRIBUTE,
"name=%s", OBJ_nid2sn(OBJ_obj2nid(obj)));
return NULL;
}

Expand Down Expand Up @@ -191,7 +193,8 @@ STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE)
return NULL;
}
if (*x != NULL && X509at_get_attr_by_NID(*x, nid, -1) != -1) {
ERR_raise(ERR_LIB_X509, X509_R_DUPLICATE_ATTRIBUTE);
ERR_raise_data(ERR_LIB_X509, X509_R_DUPLICATE_ATTRIBUTE,
"name=%s", OBJ_nid2sn(nid));
return NULL;
}

Expand Down

0 comments on commit 7760021

Please sign in to comment.