summaryrefslogtreecommitdiff
path: root/scripts/kallsyms.c
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2020-02-11 01:18:52 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2020-02-11 05:18:09 +0900
commit9d1b38958b077f6c8d4bd196a115b643d7bd6717 (patch)
tree917975e0a1e04dfb5e3ee4c4dacd33404f090889 /scripts/kallsyms.c
parentbb6d3fb354c5ee8d6bde2d576eb7220ea09862b9 (diff)
downloadlwn-9d1b38958b077f6c8d4bd196a115b643d7bd6717.tar.gz
lwn-9d1b38958b077f6c8d4bd196a115b643d7bd6717.zip
scripts/kallsyms: fix memory corruption caused by write over-run
memcpy() writes one more byte than allocated. Fixes: 8d60526999aa ("scripts/kallsyms: change table to store (strcut sym_entry *)") Reported-by: youling257 <youling257@gmail.com> Reported-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Pavel Machek <pavel@ucw.cz>
Diffstat (limited to 'scripts/kallsyms.c')
-rw-r--r--scripts/kallsyms.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index a566d8201b56..0133dfaaf352 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -210,7 +210,7 @@ static struct sym_entry *read_symbol(FILE *in)
len = strlen(name) + 1;
- sym = malloc(sizeof(*sym) + len);
+ sym = malloc(sizeof(*sym) + len + 1);
if (!sym) {
fprintf(stderr, "kallsyms failure: "
"unable to allocate required amount of memory\n");
@@ -219,7 +219,7 @@ static struct sym_entry *read_symbol(FILE *in)
sym->addr = addr;
sym->len = len;
sym->sym[0] = type;
- memcpy(sym_name(sym), name, len);
+ strcpy(sym_name(sym), name);
sym->percpu_absolute = 0;
return sym;