From ecfdad4e43d599b7f47ae2fd77d3eb13796ffd5c Mon Sep 17 00:00:00 2001 From: xppt Date: Tue, 2 Apr 2024 10:57:13 +0300 Subject: [PATCH] fix unknown stack frames for stripped elfs --- src/symbolize.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/symbolize.cc b/src/symbolize.cc index 11a9872a0..d9e71c2ac 100644 --- a/src/symbolize.cc +++ b/src/symbolize.cc @@ -642,15 +642,14 @@ OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc, return nullptr; // Malformed line. } + strncpy(out_file_name, cursor, out_file_name_size); + // Making sure |out_file_name| is always null-terminated. + out_file_name[out_file_name_size - 1] = '\0'; + // Finally, "cursor" now points to file name of our interest. FileDescriptor object_fd{ FailureRetry([cursor] { return open(cursor, O_RDONLY); })}; if (!object_fd) { - // Failed to open object file. Copy the object file name to - // |out_file_name|. - strncpy(out_file_name, cursor, out_file_name_size); - // Making sure |out_file_name| is always null-terminated. - out_file_name[out_file_name_size - 1] = '\0'; return nullptr; } return object_fd;