Kunal Sharma wrote:

>What I see happening is this:

>ENCRYPT - size of /etc/rgconf on disk is 157043 bytes
>ENCRYPT - size of /etc/rgconf_encrypted on disk is 157044 bytes.
>BROWSER saves the file to disk - size is 136 bytes (How ???)

You called 'strlen' on something that was not a string, so it gave you junk.

> Would be nice if you could provide pointers to this problem
> or if I need to do something extra here.

You supplied the answer yourself:

>> If your data can include NULs, you should not use strlen to
>> calculate the length of the buffer, you need to provide the
>> length in some other way - in your example presumably as an
>> additional parameter.

>>Carter

And there you have it. Either convert your encrypted data to strings or pass
the length along with the data through your code paths.

You can only use 'strlen' on something that you know is in fact a string.
The encrypted data is *not* a string, it's a chunk of arbitrary bytes. The
result of calling 'strlen' on it is effectively random. There is no way to
know how many bytes it holds just from looking at the data -- you need to
store that separately.

DS

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

Reply via email to