Sorry all I figured it out, I had my own memory leak that was screwing me
up.
Apologizes to all for the interruption,
brian
-----Original Message-----
From: Brian Snyder
Sent: Monday, May 01, 2000 5:37 PM
To: Ssl (E-mail)
Subject: SIGBUS on solaris w/ C++ wrapper class.... any ideas???
Hi all,
I am writing a C++ wrapper class as an interface into certain openSSL
commands, and when I call SSL_write, I get a SIGBUS. I traced through with
gdb and where this call takes place, I tried to 'print ssl' I get:
$5 = (SSL*) 0x656e7449,
then I do 'print *ssl' I get:
Cannot access memory at address 0x656e7449
This is obviously the cause for the SIGBUS as SSL_write(ssl...) tries to
make use of this structure.
Here are my machine stats:
~ 73 >uname -a
SunOS candlestick 5.7 Generic_106541-08 sun4u sparc SUNW,Ultra-5_10
~ 74 >g++ --version
2.95.2
~ 76 >gdb --version
GNU gdb 4.17
Here is my class definition, constructor, and write function... if it will
help, Ill post all my code. I get no return codes that would alert me to
any problems up until the SIGBUS.
Ive never seen anything like this before, anyone have any advise...
#ifndef __SSLWRAPPERH__
#define __SSLWRAPPERH__
#include <stdio.h>
#include <stdlib.h>
extern "C"
{
#include <openssl/ssl.h>
}
#include <OsTypes.h>
class SSLhandler
{
private:
char hostName[80];
char request[200];
int port;
SSL *ssl;
SSL_CTX *ssl_ctx;
int sock;
static bool initialized;
public:
SSLhandler(char *HostName,int Port=4433);
~SSLhandler();
void getEventKey(ulong eventID,char *key,uint16_t maxLen);
private:
SSLhandler(); //hide
SSLhandler(SSLhandler&);//hide
int prngSeed();
void openSocket(char *host,int port);
inline int writeSSL(char *request,int length);
int readSSL(char *response,int maxLen);
};
#endif //__SSLWRAPPERH__
int SSLhandler::writeSSL(char *request,int length)
{
=>uint16_t ret = SSL_write(ssl,request,length);
#ifdef __DEBUG
cout << "Bytes Written:"<< ret<< endl;
cout << "Chars Written:"<< request << endl;
#endif
return ret;
}
//This can throw a couple different string errors, be prepared!
SSLhandler::SSLhandler(char *HostName,int Port)
: ssl(NULL),ssl_ctx(NULL),port(Port)
{
if (initialized == false)
{ //One time per program execution
if (prngSeed()==false) //Seed the random number generator!
throw "PRNG Error";
//Load all necessary support routines as definied by openSLL
SSL_load_error_strings();
SSLeay_add_ssl_algorithms();
initialized = true;
}
strcpy(hostName,HostName);
ssl_ctx = SSL_CTX_new(SSLv23_client_method());
ssl = SSL_new(ssl_ctx);
//openSocket could throw an error, otherwise sets up sock
openSocket(hostName,port);
SSL_set_fd(ssl, sock);
int result = SSL_connect(ssl);
if (SSL_get_error(ssl,result) != SSL_ERROR_NONE)
{
printf ("SSL Connect Errors!\n");
while (ERR_peek_error()!=0)
printf("%s\n",ERR_error_string(ERR_get_error(),NULL));
throw "SSL Error";
}
}
Brian Snyder.vcf