Skip to content

Commit

Permalink
fix unknown stack frames for stripped elfs
Browse files Browse the repository at this point in the history
  • Loading branch information
xppt committed Apr 1, 2024
1 parent 31429d8 commit bc707c2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/symbolize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bc707c2

Please sign in to comment.