[physfs] lzma: strncpy for non-string data?

Dennis Schridde devurandom at gmx.net
Sun May 27 05:38:47 EDT 2007


Am Sonntag, 27. Mai 2007 schrieb Ryan C. Gordon:
> Dennis,
>
> This is in lzma.c, around line 316...
>
> /* !!! FIXME: strncpy for non-string data? */
> 	strncpy(outBuffer,
>              (void*) (entry->archive->folder[entry->folderIndex].cache +
>                       entry->offset + entry->position),
>              (size_t) wantedSize);
>
>
> ...is there any reason this can't be a memcpy()? If I'm reading this
> correctly, this will copy the wrong amount of data if it reads a binary
> file with an embedded zero.
This can probably be changed.
The FIXME comment is yours, I think. The bug is mine, sorry.

And actually I am not sure whether I am correct with loading the whole file 
from the archive into memory. The other archivers seem to decode only the 
required amount.
While my method is easier to implement and faster when reading from the file 
more than once, it also pushes the memory requirements.
Do you think this should be changed?

--Dennis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://icculus.org/pipermail/physfs/attachments/20070527/86916f39/attachment.pgp>


More information about the physfs mailing list