Skip to content

Commit

Permalink
chore(security): avoid use of strcpy
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi authored Mar 4, 2025
1 parent 4f007d9 commit 9585de0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/symbolize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,10 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(
Dl_info info;
if (dladdr(pc, &info)) {
if (info.dli_sname) {
if (strlen(info.dli_sname) < out_size) {
strcpy(out, info.dli_sname);
int name_length = strlen(info.dli_sname);
if (name_length < out_size) {
memcpy(out, info.dli_sname, name_length);
out[name_length] = '\0';
// Symbolization succeeded. Now we try to demangle the symbol.
DemangleInplace(out, out_size);
return true;
Expand Down

0 comments on commit 9585de0

Please # to comment.