]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: Properly check index keys
authorTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 15 Nov 2024 17:22:45 +0000 (18:22 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 19 Nov 2024 07:34:57 +0000 (01:34 -0600)
Synchronize character checks with libkmod-index.c. 8-bit ASCII chars
would turn negative (due to signed char), which index__checkstring does
not properly check for.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/247
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/depmod.c

index 98f33dcb33a5416aa7671cdb02669d0105cacdd1..2c131f55a64c7dcbe39e8de67135220c094f4a16 100644 (file)
@@ -123,7 +123,7 @@ _printf_format_(1, 2) static inline void _show(const char *fmt, ...)
 #define INDEX_VERSION_MAJOR 0x0002
 #define INDEX_VERSION_MINOR 0x0001
 #define INDEX_VERSION ((INDEX_VERSION_MAJOR << 16) | INDEX_VERSION_MINOR)
-#define INDEX_CHILDMAX 128
+#define INDEX_CHILDMAX 128u
 
 struct index_value {
        struct index_value *next;
@@ -207,7 +207,7 @@ static void index__checkstring(const char *str)
        int i;
 
        for (i = 0; str[i]; i++) {
-               int ch = str[i];
+               unsigned char ch = (unsigned char)str[i];
 
                if (ch >= INDEX_CHILDMAX)
                        CRIT("Module index: bad character '%c'=0x%x - only 7-bit ASCII is supported:"