[sword-devel] PATCH for crashes with ciphering code
dglassey at gmail.com
Fri Dec 8 04:09:59 MST 2006
On 04/12/06, Troy A. Griffitts <scribe at crosswire.org> wrote:
> Hi Martin,
> You cannot take out the line you have taken out without changing the
> logic of the code. Not having written the code, I cannot confirm that
> you have not broken anything. Please note that SWBuf::setSize will be
> sure the data buffer can handle at least 'size' number of byte. Since
> the code is modifying the raw data buffer in SWBuf, size needs to be
> reset to the actual size of the buffer. strncpy will copy NO MORE than
> size, but might copy less.
I agree. The inBuf.setSize(strlen(inBuf.c_str())) is necessary to make
sure that inBuf.end is pointing at the right place.
IMHO it is irrelevant if ((start+size) <= strlen(cacheBuf)) is a speed
hit. It is just as necessary as above so that you aren't messing
around with data over the end of the buffer.
If we want to remove the strlen(cacheBuf) then we could cache it when
cacheBuf is created. Up to you guys what you prefer on that.
I had a quick look at making cacheBuf into a SWBuf but, er, that looks
a bit hairy.
More information about the sword-devel