From eb0249519825bbaa668a344b79f8c4ec305f710b Mon Sep 17 00:00:00 2001 From: root Date: Sun, 21 Aug 2016 15:28:25 +0200 Subject: [PATCH 1/2] added fix for when an cert-extension attribute had a value of NULL that would break processing the rest of the certificate. --- src/x509.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/x509.cc b/src/x509.cc index acad881..1c9fbd7 100644 --- a/src/x509.cc +++ b/src/x509.cc @@ -277,12 +277,16 @@ Local 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){ + BIO_free(ext_bio); + data=""; + } else { + 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) { From 4e81e38603ababe78d2dadffb4a32a78ebeb4ea5 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 21 Aug 2016 15:30:27 +0200 Subject: [PATCH 2/2] idention --- src/x509.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/x509.cc b/src/x509.cc index 1c9fbd7..d87f53d 100644 --- a/src/x509.cc +++ b/src/x509.cc @@ -280,13 +280,13 @@ Local try_parse(const std::string& dataString) { char *data = (char*) malloc(bptr->length + 1); if (bptr->data == NULL){ - BIO_free(ext_bio); - data=""; + BIO_free(ext_bio); + data=""; } else { - BUF_strlcpy(data, bptr->data, bptr->length ); - data = trim(data, bptr->length); - BIO_free(ext_bio); - } + 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) {