Hi ,
I am working on Fedora core 5 and my OS version is
2.6.15-1.2054_FC5 . My GCC version is 4.1.1 20070105 (Red Hat
4.1.1-51) .
I am currently using the openssl libraries to write a simple
base64 encode routine and base64 decoding routine . My openssl version
is 0.9.8a 11 Oct 2005 .
I had did numerous unit testing of my base64 encoding and
decoding schemes and i did not get face any SigSEGV from any of the
libraries from openssl . After completing my extensive unit testing ,
i merged with my application and the below error occurs -
"Program received signal SIGSEGV, Segmentation fault.
0x003577da in SSLeay_version () from /lib/libcrypto.so.6"
Below i have attached by code for base64 decoding technique where
the above error is actually occurring . This code has been picked
from the www.openssl.org , after some very minute modifications .
-------------------------------------------------------------------------------------------------------------------------------------------------
int base64_decodestring(char* pcto_decode,char** ppcdecoded_string)
{
BIO* bio = NULL ;
BIO* bmem = NULL ;
BIO* b64 = NULL ;
BUF_MEM* bptr = NULL ;
*ppcdecoded_string = (char *)malloc(sizeof(char)*2048);
if (!*ppcdecoded_string)
{
printf("malloc failed");
return 1;
}
memset(*ppcdecoded_string, 0,sizeof(char)*2048);
b64 = BIO_new(BIO_f_base64());
bmem = BIO_new_mem_buf(pcto_decode, strlen(pcto_decode));
bmem = BIO_push(b64, bmem);
BIO_read(bmem,*ppcdecoded_string,strlen(pcto_decod e));
BIO_flush(bmem);
BIO_free_all(bmem);
BIO_free_all(b64);
return 0;
}
--------------------------------------------------------------------------------------------------------------------------------------------
i will also show the core dump below :-
#1 0x003aa1be in lh_retrieve () from /lib/libcrypto.so.6
(gdb) bt
#0 0x003577da in SSLeay_version () from /lib/libcrypto.so.6
#1 0x003aa1be in lh_retrieve () from /lib/libcrypto.so.6
#2 0x00357e1c in CRYPTO_get_ex_data_implementation () from /lib/
libcrypto.so.6
#3 0x003582fc in CRYPTO_get_ex_data_implementation () from /lib/
libcrypto.so.6
#4 0x00357b79 in CRYPTO_new_ex_data () from /lib/libcrypto.so.6
#5 0x003a1654 in BIO_set () from /lib/libcrypto.so.6
#6 0x003a16ea in BIO_new () from /lib/libcrypto.so.6
#7 0x08055df4 in base64_decodestring (
pcto_decode=0x9030250
"TlRMTVNTUAACAAAACQAJADgAAAAGgoICpprSq2j8BOYAAAAAA AAAAFwAXABBAAAABQLODgAAAA9S
\nSUNPSC1JSVMCABIAUgBJAEMATwBIAC0ASQBJAFMAAQASAFIA SQBDAE8ASAAtAEkASQBTAAQAEgBS
\nAEkAQwBPAEgALQBJAEkAUwADABIAUgBJAEMATwBIAC0ASQ". ..,
ppcdecoded_string=0xbf83610c) at base64_openssl.c:39
-----------------------------------------------------------------------------------------------------------------------------------
I cannot figure out why there could be an error from the shared
libraries . This is a big work - stopper .
Please Help !