From: Tobias Stoeckmann Date: Fri, 15 Nov 2024 17:22:45 +0000 (+0100) Subject: depmod: Properly check index keys X-Git-Tag: v34~76 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=9cbb97993462f3c1b0613bdc9cfe425d21e53356;p=thirdparty%2Fkmod.git depmod: Properly check index keys 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 Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/247 Signed-off-by: Lucas De Marchi --- diff --git a/tools/depmod.c b/tools/depmod.c index 98f33dcb..2c131f55 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -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:"