]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: fix crash when parsing addon without .cmdline section
authorLuca Boccassi <bluca@debian.org>
Mon, 13 May 2024 23:26:55 +0000 (00:26 +0100)
committerMike Yuan <me@yhndnzj.com>
Tue, 14 May 2024 06:50:58 +0000 (14:50 +0800)
Follow-up for 706ca67d3074b2a405ee8fe5de307416e4915b9f

src/shared/bootspec.c

index 42b52c88453753b3fdc4ba8be989a7246268903f..0799191a99873d96ccf3100f18d40e4be42bd536 100644 (file)
@@ -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);