summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-02-04 11:43:41 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-02-04 15:21:06 +0100
commit172f3ea324a3685a62b03edd8b03e5f09e265301 (patch)
tree7deb429b44b2f7a7455c52f221468c78ea94a724
parentd7b113dced48aaaba6db262db2ed420b47917896 (diff)
ddb: safely copy symbol names into the symtab structure
Use strncpy instead of strcpy to copy the name of a symbol into the symtab structure. Make sure that the string is properly terminated. Found using Coverity. * ddb/db_sym.c (db_add_symbol_table): Use strncpy instead of strcpy, ensure string termination.
-rw-r--r--ddb/db_sym.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ddb/db_sym.c b/ddb/db_sym.c
index beb4d18..3c8caf4 100644
--- a/ddb/db_sym.c
+++ b/ddb/db_sym.c
@@ -75,7 +75,8 @@ db_add_symbol_table(type, start, end, name, ref, map_pointer)
st->end = end;
st->private = ref;
st->map_pointer = (map_pointer == (char *)kernel_map)? 0: map_pointer;
- strcpy(st->name, name);
+ strncpy(st->name, name, sizeof st->name - 1);
+ st->name[sizeof st->name - 1] = '\0';
db_nsymtab++;