473,395 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Need Help

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
4 3762
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
5
by: John Flynn | last post by:
hi all i'm going to be quick i have an assignment due which i have no idea how to do. i work full time so i dont have the time to learn it and its due date has crept up on me .. As follows:...
0
by: xunling | last post by:
i have a question about answering ..... this topic is "need help" what do i have to write at te topic line, !after i have klicked the "answer message" button ive tried many possibilities,...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.