[v4,1/1] eal/unix: fix firmware reading with external xz helper
Checks
Commit Message
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@dpdk.org
Signed-off-by: Srikanth Yalavarthi <syalavarthi@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(-)
Comments
On Tue, Sep 26, 2023 at 4:45 PM Srikanth Yalavarthi
<syalavarthi@marvell.com> wrote:
>
> 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@dpdk.org
>
> Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
On Wed, Sep 27, 2023 at 10:20 AM David Marchand
<david.marchand@redhat.com> wrote:
> On Tue, Sep 26, 2023 at 4:45 PM Srikanth Yalavarthi
> <syalavarthi@marvell.com> wrote:
> >
> > 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@dpdk.org
> >
> > Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
>
> Reviewed-by: David Marchand <david.marchand@redhat.com>
Applied, thanks.
@@ -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