Skip to content

Commit

Permalink
eal/unix: fix firmware reading with external xz helper
Browse files Browse the repository at this point in the history
[ upstream commit 39970abcf4850e070aa4709c87bcac15cb27caf8 ]

libarchive may support xz decompression only through an
external (slower) helper.

In such a case, archive_read_support_filter_xz() returns
ARCHIVE_WARN.

Fixes: 40edb9c ("eal: handle compressed firmware")

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
  • Loading branch information
syalavarthi authored and kevintraynor committed Oct 31, 2023
1 parent acafc55 commit c8f024e
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions lib/eal/unix/eal_firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,31 @@ static int
firmware_open(struct firmware_read_ctx *ctx, const char *name, size_t blocksize)
{
struct archive_entry *e;
int err;

ctx->a = archive_read_new();
if (ctx->a == NULL)
return -1;
if (archive_read_support_format_raw(ctx->a) != ARCHIVE_OK ||
archive_read_support_filter_xz(ctx->a) != ARCHIVE_OK ||
archive_read_open_filename(ctx->a, name, blocksize) != ARCHIVE_OK ||
archive_read_next_header(ctx->a, &e) != ARCHIVE_OK) {
archive_read_free(ctx->a);
ctx->a = NULL;
return -1;
}

if (archive_read_support_format_raw(ctx->a) != ARCHIVE_OK)
goto error;

err = archive_read_support_filter_xz(ctx->a);
if (err != ARCHIVE_OK && err != ARCHIVE_WARN)
goto error;

if (archive_read_open_filename(ctx->a, name, blocksize) != ARCHIVE_OK)
goto error;

if (archive_read_next_header(ctx->a, &e) != ARCHIVE_OK)
goto error;

return 0;

error:
archive_read_free(ctx->a);
ctx->a = NULL;
return -1;
}

static ssize_t
Expand Down

0 comments on commit c8f024e

Please sign in to comment.