Skip to content

Commit 9d1b389

Browse files
committed
scripts/kallsyms: fix memory corruption caused by write over-run
memcpy() writes one more byte than allocated. Fixes: 8d60526 ("scripts/kallsyms: change table to store (strcut sym_entry *)") Reported-by: youling257 <[email protected]> Reported-by: Pavel Machek <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Tested-by: Pavel Machek <[email protected]>
1 parent bb6d3fb commit 9d1b389

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/kallsyms.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static struct sym_entry *read_symbol(FILE *in)
210210

211211
len = strlen(name) + 1;
212212

213-
sym = malloc(sizeof(*sym) + len);
213+
sym = malloc(sizeof(*sym) + len + 1);
214214
if (!sym) {
215215
fprintf(stderr, "kallsyms failure: "
216216
"unable to allocate required amount of memory\n");
@@ -219,7 +219,7 @@ static struct sym_entry *read_symbol(FILE *in)
219219
sym->addr = addr;
220220
sym->len = len;
221221
sym->sym[0] = type;
222-
memcpy(sym_name(sym), name, len);
222+
strcpy(sym_name(sym), name);
223223
sym->percpu_absolute = 0;
224224

225225
return sym;

0 commit comments

Comments
 (0)