|
|
77be88 |
diff -urNp a/snmplib/snmp_openssl.c b/snmplib/snmp_openssl.c
|
|
|
77be88 |
--- a/snmplib/snmp_openssl.c 2021-06-09 12:38:23.196037329 +0200
|
|
|
77be88 |
+++ b/snmplib/snmp_openssl.c 2021-06-09 12:44:11.782503048 +0200
|
|
|
77be88 |
@@ -284,31 +284,30 @@ _cert_get_extension(X509_EXTENSION *oex
|
|
|
77be88 |
}
|
|
|
77be88 |
if (X509V3_EXT_print(bio, oext, 0, 0) != 1) {
|
|
|
77be88 |
snmp_log(LOG_ERR, "could not print extension!\n");
|
|
|
77be88 |
- BIO_vfree(bio);
|
|
|
77be88 |
- return NULL;
|
|
|
77be88 |
+ goto out;
|
|
|
77be88 |
}
|
|
|
77be88 |
|
|
|
77be88 |
space = BIO_get_mem_data(bio, &data);
|
|
|
77be88 |
if (buf && *buf) {
|
|
|
77be88 |
- if (*len < space)
|
|
|
77be88 |
- buf_ptr = NULL;
|
|
|
77be88 |
- else
|
|
|
77be88 |
- buf_ptr = *buf;
|
|
|
77be88 |
+ if (*len < space +1) {
|
|
|
77be88 |
+ snmp_log(LOG_ERR, "not enough buffer space to print extension\n");
|
|
|
77be88 |
+ goto out;
|
|
|
77be88 |
+ }
|
|
|
77be88 |
+ buf_ptr = *buf;
|
|
|
77be88 |
+ } else {
|
|
|
77be88 |
+ buf_ptr = calloc(1, space + 1);
|
|
|
77be88 |
}
|
|
|
77be88 |
- else
|
|
|
77be88 |
- buf_ptr = calloc(1,space + 1);
|
|
|
77be88 |
|
|
|
77be88 |
if (!buf_ptr) {
|
|
|
77be88 |
- snmp_log(LOG_ERR,
|
|
|
77be88 |
- "not enough space or error in allocation for extenstion\n");
|
|
|
77be88 |
- BIO_vfree(bio);
|
|
|
77be88 |
- return NULL;
|
|
|
77be88 |
+ snmp_log(LOG_ERR, "error in allocation for extenstion\n");
|
|
|
77be88 |
+ goto out;
|
|
|
77be88 |
}
|
|
|
77be88 |
memcpy(buf_ptr, data, space);
|
|
|
77be88 |
buf_ptr[space] = 0;
|
|
|
77be88 |
if (len)
|
|
|
77be88 |
*len = space;
|
|
|
77be88 |
|
|
|
77be88 |
+out:
|
|
|
77be88 |
BIO_vfree(bio);
|
|
|
77be88 |
|
|
|
77be88 |
return buf_ptr;
|
|
|
77be88 |
@@ -479,7 +478,7 @@ netsnmp_openssl_cert_dump_extensions(X50
|
|
|
77be88 |
{
|
|
|
77be88 |
X509_EXTENSION *extension;
|
|
|
77be88 |
const char *extension_name;
|
|
|
77be88 |
- char buf[SNMP_MAXBUF_SMALL], *buf_ptr = buf, *str, *lf;
|
|
|
77be88 |
+ char buf[SNMP_MAXBUF], *buf_ptr = buf, *str, *lf;
|
|
|
77be88 |
int i, num_extensions, buf_len, nid;
|
|
|
77be88 |
|
|
|
77be88 |
if (NULL == ocert)
|
|
|
77be88 |
@@ -499,6 +498,11 @@ netsnmp_openssl_cert_dump_extensions(X50
|
|
|
77be88 |
extension_name = OBJ_nid2sn(nid);
|
|
|
77be88 |
buf_len = sizeof(buf);
|
|
|
77be88 |
str = _cert_get_extension_str_at(ocert, i, &buf_ptr, &buf_len, 0);
|
|
|
77be88 |
+ if (!str) {
|
|
|
77be88 |
+ DEBUGMSGT(("9:cert:dump", " %2d: %s\n", i,
|
|
|
77be88 |
+ extension_name));
|
|
|
77be88 |
+ continue;
|
|
|
77be88 |
+ }
|
|
|
77be88 |
lf = strchr(str, '\n'); /* look for multiline strings */
|
|
|
77be88 |
if (NULL != lf)
|
|
|
77be88 |
*lf = '\0'; /* only log first line of multiline here */
|