libarchive: treat one "FIXME: avoid seek" patch issue
Denys Vlasenko
vda.linux at googlemail.com
Sun May 26 11:44:07 UTC 2019
On Sun, May 26, 2019 at 12:48 AM Rostyslav Kurylo
<rostawesomegd at gmail.com> wrote:
>
> Hi everyone,
>
> I was playing around with the busybox master branch and found an
> issue with the "libarchive: treat one "FIXME: avoid seek"" patch
> (commit hash dff2bd733fc2dac08d34f2cfad0e68aeb8e7a7a2).
>
> The xmalloc_read_with_inital_buf() accepts xstate->signature_skipped as the
> buffer offset/initial buffer size. In case of uncompressed files
> (no known 2-byte signature was found at the start), the signature_skipped is 0
> (see open_transformer.c:355).
> However, the src_fd file position is already shifted, and the first two bytes
> have been already read into the xstate by open_transformer() function.
> Passing 0 as offset/buffer size leads to the first two bytes being lost.
you are right, it's misplaced:
--- a/archival/libarchive/open_transformer.c
+++ b/archival/libarchive/open_transformer.c
@@ -352,13 +352,13 @@ void* FAST_FUNC
xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_
* read(4, "LF\2\1\1\0\0\0\0"...
* ...and we avoided seeking on the fd! :)
*/
- xstate->signature_skipped = 0;
image = xmalloc_read_with_initial_buf(
xstate->src_fd,
maxsz_p,
xmemdup(&xstate->magic, xstate->signature_skipped),
xstate->signature_skipped
);
+ xstate->signature_skipped = 0;
}
More information about the busybox
mailing list