Skip to content

Out of memory on openssl 1.1.1w hpux #52

@timlegge

Description

@timlegge

Just testing the current code on hpux before testing the opensslv3 updates and noticed that after #51 is fixed we have an out of memory issue.

It appears the the call to BIO_get_mem_ptr result in an invalid length in bptr->length or maybe the data there is just incorrect.

The following fixes the issue but I am awaiting some feedback from the openssl people to see if there is any reason not to make this the default...

diff --git a/RSA.xs b/RSA.xs
index 5f5cfae..b6c0509 100644
--- a/RSA.xs
+++ b/RSA.xs
@@ -165,11 +165,13 @@ SV* cor_bn2sv(const BIGNUM* p_bn)

 SV* extractBioString(BIO* p_stringBio)
 {
     SV* sv;
-    BUF_MEM* bptr;
+    char *datap;
+    long datasize = 0;
 
     CHECK_OPEN_SSL(BIO_flush(p_stringBio) == 1);
-    BIO_get_mem_ptr(p_stringBio, &bptr);
-    sv = newSVpv(bptr->data, bptr->length);
+
+    datasize = BIO_get_mem_data(p_stringBio, &datap);
+    sv = newSVpv(datap, datasize);
 
     CHECK_OPEN_SSL(BIO_set_close(p_stringBio, BIO_CLOSE) == 1);
     BIO_free(p_stringBio);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions