By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,412 Members | 917 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,412 IT Pros & Developers. It's quick & easy.

Need Help

P: n/a
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 !

Jul 12 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Thu, 12 Jul 2007 08:26:33 -0700, pycraze wrote:
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);
sizeof(char) is always 1. And that cast is useless.
*ppcdecoded_string = malloc(2048);
if (!*ppcdecoded_string)
{
printf("malloc failed");
Write that to stderr, rather than to stdout, and I'd end the
warning with a newline. Also, since you return a value, you can
have the caller print the warning if base64_decodestring() returns
1.
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));
What does that function do? If, as I guess, it duplicates the
first arg2 bytes of arg1 into a new object, you need to use
strlen(pcto_decode) + 1 to make room for the terminating '\0'.
But this is a guess.
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;
}
--
Army1987 (Replace "NOSPAM" with "email")
"Never attribute to malice that which can be adequately explained
by stupidity." -- R. J. Hanlon (?)

Jul 12 '07 #2

P: n/a
On Jul 13, 4:17 am, Army1987 <army1...@NOSPAM.itwrote:
On Thu, 12 Jul 2007 08:26:33 -0700, pycraze wrote:
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 thewww.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);

sizeof(char) is always 1. And that cast is useless.
*ppcdecoded_string = malloc(2048);
if (!*ppcdecoded_string)
{
printf("malloc failed");

Write that to stderr, rather than to stdout, and I'd end the
warning with a newline. Also, since you return a value, you can
have the caller print the warning if base64_decodestring() returns
1. 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));

What does that function do? If, as I guess, it duplicates the
first arg2 bytes of arg1 into a new object, you need to use
strlen(pcto_decode) + 1 to make room for the terminating '\0'.
But this is a guess.
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;
}

--
Army1987 (Replace "NOSPAM" with "email")
"Never attribute to malice that which can be adequately explained
by stupidity." -- R. J. Hanlon (?)
Thanks for your inputs, will try and will get back .

Jul 13 '07 #3

P: n/a
On Thu, 12 Jul 2007 22:28:50 -0700, pycraze wrote:
On Jul 13, 4:17 am, Army1987 <army1...@NOSPAM.itwrote:
>On Thu, 12 Jul 2007 08:26:33 -0700, pycraze wrote:
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 thewww.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);

sizeof(char) is always 1. And that cast is useless.
*ppcdecoded_string = malloc(2048);
if (!*ppcdecoded_string)
{
printf("malloc failed");

Write that to stderr, rather than to stdout, and I'd end the
warning with a newline. Also, since you return a value, you can
have the caller print the warning if base64_decodestring() returns
1. 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));

What does that function do? If, as I guess, it duplicates the
first arg2 bytes of arg1 into a new object, you need to use
strlen(pcto_decode) + 1 to make room for the terminating '\0'.
But this is a guess.
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;
}
[snip signature]
Thanks for your inputs, will try and will get back .
But since these functions are not standard C, you'd better ask in
a group about that which defines them (or to post its source here,
if you wrote them yourself).

--
Army1987 (Replace "NOSPAM" with "email")
"Never attribute to malice that which can be adequately explained
by stupidity." -- R. J. Hanlon (?)

Jul 13 '07 #4

P: n/a
If you want to decode then should you not be using

BIO_read(b64,*ppcdecoded_string,strlen(pcto_decode ));
If you read from bmem, then you should only get the content of
pcto_decode.

Jul 18 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.