Blame SOURCES/0009-trivial-Fix-a-buffer-overread-spotted-by-AddressSani.patch

003958
From b743836b16c64e2d726f85113cd4ab6f18ed4df0 Mon Sep 17 00:00:00 2001
003958
From: Richard Hughes <richard@hughsie.com>
003958
Date: Mon, 8 Feb 2021 16:47:05 +0000
003958
Subject: [PATCH 09/11] trivial: Fix a buffer-overread spotted by
003958
 AddressSanitizer
003958
003958
---
003958
 libfwupdplugin/fu-common.c | 6 ++----
003958
 1 file changed, 2 insertions(+), 4 deletions(-)
003958
003958
diff --git libfwupdplugin/fu-common.c libfwupdplugin/fu-common.c
003958
index d4dd4aef..094f2d23 100644
003958
--- libfwupdplugin/fu-common.c
003958
+++ libfwupdplugin/fu-common.c
003958
@@ -1856,14 +1856,12 @@ fu_common_strsafe (const gchar *str, gsize maxsz)
003958
 	gboolean valid = FALSE;
003958
 	g_autoptr(GString) tmp = NULL;
003958
 
003958
-	g_return_val_if_fail (maxsz > 0, NULL);
003958
-
003958
 	/* sanity check */
003958
-	if (str == NULL)
003958
+	if (str == NULL || maxsz == 0)
003958
 		return NULL;
003958
 
003958
 	/* replace non-printable chars with '.' */
003958
-	tmp = g_string_sized_new (strlen (str));
003958
+	tmp = g_string_sized_new (maxsz);
003958
 	for (gsize i = 0; str[i] != '\0' && i < maxsz; i++) {
003958
 		if (!g_ascii_isprint (str[i])) {
003958
 			g_string_append_c (tmp, '.');
003958
-- 
003958
2.29.2
003958