diff options
author | android-build-prod (mdb) <android-build-team-robot@google.com> | 2018-05-07 16:39:51 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-05-07 16:39:51 +0000 |
commit | 0a59152418944d533cbfe5db1272994253fabcfa (patch) | |
tree | efb4d76c8bec056a5c3536c66ad1ee17fb34baa9 | |
parent | db822be4307656ed8446e2f5fd100d1201846396 (diff) | |
parent | 4d50972ad74cc121cf8c885f08ad2a9fa2a45497 (diff) | |
download | extras-android-p-preview-3.tar.gz |
Merge "Avoid potential non-terminated string"android-p-preview-3android-p-preview-2
-rw-r--r-- | showmap/showmap.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/showmap/showmap.cpp b/showmap/showmap.cpp index 1e1d7980..799cc857 100644 --- a/showmap/showmap.cpp +++ b/showmap/showmap.cpp @@ -86,6 +86,7 @@ static int parse_header(const char* line, const mapinfo* prev, mapinfo** mi) { strncpy(name, "[anon]", sizeof(name)); } } + name[sizeof(name) - 1] = '\0'; // Assure we're null-terminated. const int name_size = strlen(name) + 1; struct mapinfo* info = reinterpret_cast<mapinfo*>(calloc(1, sizeof(mapinfo) + name_size)); @@ -98,7 +99,7 @@ static int parse_header(const char* line, const mapinfo* prev, mapinfo** mi) { info->end = end; info->is_bss = is_bss; info->count = 1; - strncpy(info->name, name, name_size); + memcpy(info->name, name, name_size); *mi = info; return 0; |