diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 98a5cfbeb2a0e3..275044b840dcbe 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -33,7 +33,7 @@ #define KSYM_NAME_LEN 512 /* A substantially bigger size than the current maximum. */ -#define KSYM_NAME_LEN_BUFFER 2048 +#define KSYM_NAME_LEN_BUFFER 2048 _Static_assert( KSYM_NAME_LEN_BUFFER == KSYM_NAME_LEN * 4, "Please keep KSYM_NAME_LEN_BUFFER in sync with KSYM_NAME_LEN" @@ -215,7 +215,7 @@ static struct sym_entry *read_symbol(FILE *in) rc = fscanf(in, "%llx %c %" _stringify(KSYM_NAME_LEN_BUFFER) "s\n", &addr, &type, name); if (rc != 3) { - if (rc != EOF && fgets(name, KSYM_NAME_LEN_BUFFER + 1, in) == NULL) + if (rc != EOF && fgets(name, sizeof(name), in) == NULL) fprintf(stderr, "Read error or end of file.\n"); return NULL; }