You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.6 KiB
43 lines
1.6 KiB
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
|
To: devel@lists.libvirt.org
|
|
Subject: [PATCH] util: avoid overflow in hextable buffer
|
|
Date: Mon, 20 Jan 2025 10:09:24 +0000
|
|
Message-ID: <20250120100924.3864818-1-berrange@redhat.com>
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
The assigned string is 17 chars long once the trailing nul is taken
|
|
into account. This triggers a warning with GCC 15
|
|
|
|
src/util/virsystemd.c: In function ‘virSystemdEscapeName’:
|
|
src/util/virsystemd.c:59:38: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
|
|
59 | static const char hextable[16] = "0123456789abcdef";
|
|
| ^~~~~~~~~~~~~~~~~~
|
|
|
|
Switch to a dynamically sized array as used in all the other places
|
|
we have a hextable array.
|
|
|
|
See also: https://gcc.gnu.org/PR115185
|
|
Reported-by: Yaakov Selkowitz <yselkowi@redhat.com>
|
|
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
---
|
|
src/util/virsystemd.c | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
|
|
index 5b772e29dd..d46e5f74fc 100644
|
|
--- a/src/util/virsystemd.c
|
|
+++ b/src/util/virsystemd.c
|
|
@@ -56,7 +56,7 @@ struct _virSystemdActivationEntry {
|
|
static void virSystemdEscapeName(virBuffer *buf,
|
|
const char *name)
|
|
{
|
|
- static const char hextable[16] = "0123456789abcdef";
|
|
+ static const char hextable[] = "0123456789abcdef";
|
|
|
|
#define ESCAPE(c) \
|
|
do { \
|
|
--
|
|
2.47.1
|
|
|
|
|