Skip to content

Commit eca090f

Browse files
authored
Merge pull request torvalds#756 from ojeda/new-kallsyms-patches
kallsyms: provide a bigger buffer to report the real length
2 parents 426f7e4 + 49aab5e commit eca090f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

scripts/kallsyms.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232

3333
#define KSYM_NAME_LEN 512
3434

35+
/* A substantially bigger size than the current maximum. */
36+
#define KSYM_NAME_LEN_BUFFER 2048
37+
_Static_assert(
38+
KSYM_NAME_LEN_BUFFER == KSYM_NAME_LEN * 4,
39+
"Please keep KSYM_NAME_LEN_BUFFER in sync with KSYM_NAME_LEN"
40+
);
41+
3542
struct sym_entry {
3643
unsigned long long addr;
3744
unsigned int len;
@@ -200,15 +207,15 @@ static void check_symbol_range(const char *sym, unsigned long long addr,
200207

201208
static struct sym_entry *read_symbol(FILE *in)
202209
{
203-
char name[KSYM_NAME_LEN+1], type;
210+
char name[KSYM_NAME_LEN_BUFFER+1], type;
204211
unsigned long long addr;
205212
unsigned int len;
206213
struct sym_entry *sym;
207214
int rc;
208215

209-
rc = fscanf(in, "%llx %c %" _stringify(KSYM_NAME_LEN) "s\n", &addr, &type, name);
216+
rc = fscanf(in, "%llx %c %" _stringify(KSYM_NAME_LEN_BUFFER) "s\n", &addr, &type, name);
210217
if (rc != 3) {
211-
if (rc != EOF && fgets(name, KSYM_NAME_LEN + 1, in) == NULL)
218+
if (rc != EOF && fgets(name, KSYM_NAME_LEN_BUFFER + 1, in) == NULL)
212219
fprintf(stderr, "Read error or end of file.\n");
213220
return NULL;
214221
}

0 commit comments

Comments
 (0)