Skip to content

Commit

Permalink
Fix potential NULL pointer dereference (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkostic authored Jun 22, 2023
1 parent 8402a6e commit f49fc13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crypto/x509/name_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ static int do_name_ex(BIO *out, const X509_NAME *n, int indent,
} else {
objbuf = OBJ_nid2sn(fn_nid);
}
if (objbuf == NULL) {
return -1;
}

int objlen = strlen(objbuf);
if (!maybe_write(out, objbuf, objlen) ||
!maybe_write(out, sep_eq, sep_eq_len)) {
Expand Down
3 changes: 3 additions & 0 deletions crypto/x509/x509_req.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj,
for (; lastpos < n; lastpos++) {
const X509_ATTRIBUTE *attr =
sk_X509_ATTRIBUTE_value(req->req_info->attributes, lastpos);
if (attr == NULL) {
return -1;
}
if (OBJ_cmp(attr->object, obj) == 0) {
return lastpos;
}
Expand Down

0 comments on commit f49fc13

Please sign in to comment.