Amit Ben Shahar wrote:
Does anyone know if a buffer passed to ssl_write (or any other method)
must remain valid (i.e not freed) for any period.
for example, if i have this code:
// allocate buffer
char* tmpBuff = (char*)malloc(1024);
// .. some code to put data in buff
// write buffer to ssl
ssl_write(mSsl, buff, dataLength);
// free buffer now
free tmpBuff;
is this legal?
(considering that ssl_write did not return want_read/want_write)
Thanks
Yes. The lifetime of the buffer "tmpBuff" is exactly that of the
invocation of the ssl_write() call.
Internally libssl will copy the bytes from "tmpBuff" it can use/eat at
that time into an internal buffer and those bytes eaten are given as the
return value of ssl_write(). This maybe between 0 and dataLength.
You then have to manage and window your data for the next call you make
to ssl_write() so those eaten last time are not given again next time.
Much like the write() system call on Unix when the file-descriptor is a
network socket.
Darryl
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org