summaryrefslogtreecommitdiff
blob: 42d5915397b8e3547c9aa1fef439f06c4463ad81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
From 7e502cf7d3da00a978201455f3a3799ae4aded75 Mon Sep 17 00:00:00 2001
From: Richard Hughes <richard@hughsie.com>
Date: Mon, 6 Mar 2023 16:56:05 +0000
Subject: [PATCH] Fix a critical warning when parsing an empty kernel cmdline

Fix the bounds check so we never pass a bufsz of zero to fu_strsplit().

Resolves: https://github.com/fwupd/fwupd/issues/5575
--- a/libfwupdplugin/fu-kernel.c
+++ b/libfwupdplugin/fu-kernel.c
@@ -253,7 +253,7 @@ fu_kernel_get_cmdline(GError **error)
 	if (!g_file_get_contents("/proc/cmdline", &buf, &bufsz, error))
 		return NULL;
 	hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
-	if (bufsz > 0) {
+	if (bufsz > 1) {
 		g_auto(GStrv) tokens = fu_strsplit(buf, bufsz - 1, " ", -1);
 		for (guint i = 0; tokens[i] != NULL; i++) {
 			g_auto(GStrv) kv = NULL;