> From: owner-openssl-us...@openssl.org On Behalf Of Jeffrey Walton
> Sent: Monday, 11 February, 2013 01:12

> I'm trying to memory map a file. Does OpenSSL BIO's allow this?
> 
> I seem to be failing on BIO_read_filename with a `ret` of 0. The docs
> state I should expect `ret` of 1. When I look for the problem, I'm
> getting an error code of 0 (`err`, success).
> 
(BIO_read_filename = BIO_ctrl _SET_FILENAME on a mem-BIO) 
That doesn't make sense. OpenSSL doesn't map a file itself; 
that isn't portable. If you *already* have a file mapped into 
memory by e.g. mmap in Unix and something different in Windows, 
you can create a *readonly* mem-BIO on that memory with 
BIO_new_mem_buf. I don't think you can do this for write; 
writing to a mem-BIO must be able to re-allocate the underlying 
buffer when it thinks necessary, and that can't work for a file 
mapped to a fixed area of memory.

BIO_ctrl of an option inapplicable to mem-BIO returns 0 but doesn't 
set anything in the error queue. Yes, this isn't too helpful.

> I ask because the doc's appear to be incorrect on the return type of
> BIO_read_filename. When I try and use an `int`, I get a size warning
> (long instead of int). So I suspect the docs may be wrong.
> http://www.openssl.org/docs/crypto/BIO_s_file.html.
> 
I suspect at some point in the distant past BIO_read_filename was 
a separate routine and did return int. When it was combined into 
the more general BIO_ctrl/file_ctrl mechanism, that handles many 
options some of which need to return long, and the manpage probably 
wasn't updated.


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to