Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix for parsing a certificate with an extension attribute with a NULL-value #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/x509.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,16 @@ Local<Value> try_parse(const std::string& dataString) {
BUF_MEM *bptr;
BIO_get_mem_ptr(ext_bio, &bptr);
BIO_set_close(ext_bio, BIO_CLOSE);

char *data = (char*) malloc(bptr->length + 1);
BUF_strlcpy(data, bptr->data, bptr->length + 1);
data = trim(data, bptr->length);

BIO_free(ext_bio);
if (bptr->data == NULL){
Copy link
Owner

@Southern Southern Oct 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the better option would be to not run the allocation or anything that deals with data unless bptr->data != NULL.

BIO_free(ext_bio);
data="";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

free(data) :)

} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove else, please.

BUF_strlcpy(data, bptr->data, bptr->length );
data = trim(data, bptr->length);
BIO_free(ext_bio);
}

unsigned nid = OBJ_obj2nid(obj);
if (nid == NID_undef) {
Expand Down