From 2ae49d2cd5c3446ec8f930b60d5b4d4b8caf073c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Fri, 18 Sep 2009 08:24:22 +0000 Subject: [PATCH] openssl fixed --- src/openssl.hxx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/openssl.hxx b/src/openssl.hxx index 15e706d..5f0f05d 100644 --- a/src/openssl.hxx +++ b/src/openssl.hxx @@ -144,13 +144,14 @@ namespace openssl { X509(): _x509(X509_new()) { if (!_x509) throw allocation_failed(); } - X509(const X509& o) _x509(0) { - char* d(0); + X509(const X509& o): _x509(0) { + unsigned char* d(0); int len(i2d_X509(o._x509, &d)); if (!len) throw x509_copy_failed(); - char* d1(d); + const unsigned char* d2(d); _x509 = d2i_X509(0, &d2, len); - if (d2!=d+len || !_x509) throw x509_copy_failed(); + free(d); + if (!_x509) throw x509_copy_failed(); } //! Take over OpenSSL allocated certificate. X509(::X509 *x509): _x509(x509) { @@ -162,12 +163,13 @@ namespace openssl { X509& operator=(const X509& o) { X509_free(_x509); _x509 = 0; - char* d(0); + unsigned char* d(0); int len(i2d_X509(o._x509, &d)); if (!len) throw x509_copy_failed(); - char* d1(d); + const unsigned char* d2(d); + free(d); _x509 = d2i_X509(0, &d2, len); - if (d2!=d+len || !_x509) throw x509_copy_failed(); + if (!_x509) throw x509_copy_failed(); } private: ::X509* _x509; @@ -255,21 +257,22 @@ namespace openssl { BIO() {} ~BIO() { try { - close() + close(); } catch (...) { if (!std::uncaught_exception()) throw; } } void connect(const std::string& hostPort) { close(); - if (_bio = BIO_new_connect(hostPort.c_str())) + if (_bio = BIO_new_connect(const_cast(hostPort.c_str()))) throw bio_connection_failed(hostPort); + // ... } void close() { //! @todo tbd } private: - BIO* _bio; + ::BIO* _bio; }; }