-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix potential NULL pointer dereference #1067
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -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) { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this can happen, since n was set the number of attributes, if I understood correctly. There is a similar code here Lines 153 to 155 in 8402a6e
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I had the same thought but I'm not 100% certain it can't happen. The additional check is very cheap anyway, so no harm in having it. |
||||||||
return -1; | ||||||||
} | ||||||||
if (OBJ_cmp(attr->object, obj) == 0) { | ||||||||
return lastpos; | ||||||||
} | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the documentation of
OBJ_obj2nid()
called on l. 174,aws-lc/include/openssl/obj.h
Lines 110 to 113 in cfce39d
the
else
branch should be for a known nid. If we prefer to be safe still, maybe the check for NULL would be inside theelse
branch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's safer to have the
NULL
check right before callingstrlen
unconditionally?