From c98f2b8167fa3d0d782ddcf51bee40261f40bdcb Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Tue, 14 May 2024 00:26:55 +0100 Subject: [PATCH] bootctl: fix crash when parsing addon without .cmdline section Follow-up for 706ca67d3074b2a405ee8fe5de307416e4915b9f --- src/shared/bootspec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index 42b52c8845..0799191a99 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -783,9 +783,11 @@ static int find_cmdline_section( return 0; r = pe_read_section_data(fd, pe_header, sections, ".cmdline", PE_SECTION_SIZE_MAX, (void**) &cmdline, NULL); - if (r == -ENXIO) /* cmdline is optional */ + if (r == -ENXIO) { /* cmdline is optional */ *ret_cmdline = NULL; - else if (r < 0) + return 0; + } + if (r < 0) return log_warning_errno(r, "Failed to read .cmdline section of '%s': %m", path); word = strdup(cmdline);