Skip to content

Commit

Permalink
depmod: Properly check index keys
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
stoeckmann committed Nov 15, 2024
1 parent 16ea23b commit 7060d3a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/depmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,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;
Expand Down Expand Up @@ -208,7 +208,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:"
Expand Down

0 comments on commit 7060d3a

Please sign in to comment.