Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

BIO_get_mem_data vs get_mem_ptr

612 views
Skip to first unread message

Varun

unread,
Jun 8, 2012, 8:42:07 AM6/8/12
to
Team,

I am actually confused between the use cases for the above two macros?
I see, sometimes one works well, and sometimes the other, but I am not able to figure out when to prefer one over other. FOr now, I try one, and if doesn't work out, I try using other.
For isntance, I have X509 *ptr= NULL;
Once I have ptr valid and everything's done, I wanted to store this as char *(PEM formatted string).
therefore i used the following code

BIO *b = NULL;
char buff[2000] ={0,};
int len = 0;

b = BIO_new(BIO_s_mem());
PEM_write_bio_X509(b, ptr);
len = BIO_get_mem_data(b, &buff);
for (c =0; c < len; c++) printf(%c", buff[c]);

The output of this is weird and I didn't understand what was it,

anyway, when I replaced BIO_get_mem_data with BIO_get_mem_ptr, things worked out fine.
Any clarification, why one works here and other fails?


PS: Openssl didn't give any error in both cases, so both cases all API's were successful.
0 new messages