Le lundi 28 mai 2012 à 17:25 -0400, Dave Thompson a écrit : > > From: owner-openssl-us...@openssl.org On Behalf Of ml > > Sent: Saturday, 26 May, 2012 16:18 > > > I try to realize as base64 encoding > > char *base64(char *input, int length) > > { > > BIO *bmem, *b64; > > BUF_MEM *bptr; > > > > b64 = BIO_new(BIO_f_base64()); > > bmem = BIO_new(BIO_s_mem()); > > b64 = BIO_push(b64, bmem); > > BIO_write(b64, input, length); > > BIO_flush(b64); > > BIO_get_mem_ptr(b64, &bptr); > > > > char *buff = (char *)malloc(bptr->length+1); > > memcpy(buff, bptr->data, bptr->length); > > buff[bptr->length] = 0; > > > > BIO_free_all(b64); > > > > return buff; > > } > > but it does not work can you help me > > > It works for me, with the needed #include's and call added. > What exactly is your problem? What did it do, what did you > expect, and how do those differ? >
I am very happy to receive an answer to my question. I started and my only sources for the moment is the K & R in my example smtp client join there is an error during the execution for the second time in my hand and base64 function following the crypt connection with the mail server, which fails during //PASSWORD memset(buf, 0, 1500); sprintf(buf, "********"); //memset(pass, 0, strlen(pass)); //base64(pass, buf, strlen(buf)); //buf_pass = buf; pass = base64 ( buf , strlen(buf)); sprintf(buf, "%s\r\n", pass); send_line(ssl,buf); // this line fail recv_line(ssl); // this line is never executed free(pass); > I note the cast of malloc to (char*) is suspicious. > If you #include'd <stdlib.h> as is required to correctly > declare malloc, no cast is needed in C since about 1989. > A cast is needed in C++, ut in C++ you should normally use > (typesafe) new and delete rather than malloc/free/etc. > > And a call to malloc *without* #include'ing <stdlib.h> > is not allowed in either current C (C99 or later) or C++, > but the use of a declaration after executable statements > within a block, as you have, is *only* allowed in those. > > Also you should always check if malloc/calloc/realloc > returned a null pointer (failed) before using it. In some > applications you can actually handle the error usefully, > and even when you can't a clear and specific assert() or > similar suicide is better than an unexplained fault. > (Also fopen, tmpnam, getenv, etc, etc.) > > If you are using some sort of nonstandard C (or C++, or even > some other C-like something), give details; it may or may not > be sufficiently compatible with C as used for OpenSSL. > > all that really speaks to me and discution me towards the right path but for now I go to my pace I 'am trying to cultivate the reading pretty gnu c thank you if you find something to help me and find the solution to my problem simple smtp client > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List openssl-users@openssl.org > Automated List Manager majord...@openssl.org -- http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC2626742 gpg --keyserver pgp.mit.edu --recv-key C2626742 http://urlshort.eu fakessh @ http://gplus.to/sshfake http://gplus.to/sshswilting http://gplus.to/john.swilting https://lists.fakessh.eu/mailman/ This list is moderated by me, but all applications will be accepted provided they receive a note of presentation
signature.asc
Description: Ceci est une partie de message numériquement signée