Subject: | memory leaks in OCSP handling - patch included |
Hi,
there are some small memory leaks in the OCSP handling.
A tested patch against 1.81 is included.
Regards,
Steffen
Subject: | Net-SSLeay-1.81.patch |
diff -uw Net-SSLeay-1.81.orig/SSLeay.xs Net-SSLeay-1.81/SSLeay.xs
--- Net-SSLeay-1.81.orig/SSLeay.xs 2017-03-04 05:25:15.000000000 +0100
+++ Net-SSLeay-1.81/SSLeay.xs 2017-04-16 20:17:30.345322482 +0200
@@ -5959,7 +5959,7 @@
OCSP_CERTID *id;
int i;
STRLEN len;
- unsigned char *pc,*pi;
+ unsigned char *pi;
if (!ssl) croak("not a SSL object");
ctx = SSL_get_SSL_CTX(ssl);
@@ -5974,15 +5974,15 @@
if (!(issuer = find_issuer(cert,store,chain)))
croak("cannot find issuer certificate");
if (!(id = OCSP_cert_to_id(EVP_sha1(),cert,issuer)))
- croak("out of memory for generating OCSO certid");
- if (!(len = i2d_OCSP_CERTID(id,NULL)))
+ croak("out of memory for generating OCSP certid");
+
+ pi = NULL;
+ if (!(len = i2d_OCSP_CERTID(id,&pi)))
croak("OCSP certid has no length");
- Newx(pc,len,unsigned char);
- if (!pc) croak("out of memory");
- pi = pc;
- i2d_OCSP_CERTID(id,&pi);
- XPUSHs(sv_2mortal(newSVpv((char*)pc,len)));
- Safefree(pc);
+ XPUSHs(sv_2mortal(newSVpvn((char *)pi, len)));
+
+ free(pi);
+ OCSP_CERTID_free(id);
}
@@ -6204,6 +6204,7 @@
croak("%s", error);
}
}
+ OCSP_BASICRESP_free(bsr);
if (!want_array)
XPUSHs(sv_2mortal(newSViv(nextupd)));