static char *ssl_var_lookup_ssl_cert_dn_oneline(apr_pool_t *p, request_rec *r,
X509_NAME *xsname)
{
- char *result;
+ char *result = NULL;
SSLDirConfigRec *dc;
int legacy_format = 0;
if (r) {
return NULL;
X509_NAME_print_ex(bio, xsname, 0, flags);
n = BIO_pending(bio);
- result = apr_palloc(p, n+1);
- n = BIO_read(bio, result, n);
- result[n] = NUL;
+ if (n > 0) {
+ result = apr_palloc(p, n+1);
+ n = BIO_read(bio, result, n);
+ result[n] = NUL;
+ }
BIO_free(bio);
}
return result;