[PATCH v4 1/1] eal/unix: fix firmware reading with external xz helper
Srikanth Yalavarthi
syalavarthi at marvell.com
Tue Sep 26 16:44:54 CEST 2023
libarchive may support xz decompression only through an
external (slower) helper.
In such a case, archive_read_support_filter_xz() returns
ARCHIVE_WARN.
Fixes: 40edb9c0d36b ("eal: handle compressed firmware")
Cc: stable at dpdk.org
Signed-off-by: Srikanth Yalavarthi <syalavarthi at marvell.com>
---
v4:
* updated commit message
* fixed checking archive_read_next_header
v3:
* removed gerrit change-id
v2:
* updated code as per review comments
lib/eal/unix/eal_firmware.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/lib/eal/unix/eal_firmware.c b/lib/eal/unix/eal_firmware.c
index d1616b0bd9..1a7cf8e7b7 100644
--- a/lib/eal/unix/eal_firmware.c
+++ b/lib/eal/unix/eal_firmware.c
@@ -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
--
2.41.0
More information about the stable
mailing list