Skip to content

Commit

Permalink
Use strncpy as proposed by Hilko Bengen in PR VirusTotal#314
Browse files Browse the repository at this point in the history
It does the same but is more compact and elegant.
  • Loading branch information
plusvic committed Jul 30, 2015
1 parent 6ad1182 commit 14dbf62
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions libyara/modules/pe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1304,12 +1304,8 @@ void pe_parse_header(
if (!struct_fits_in_pe(pe, section, IMAGE_SECTION_HEADER))
break;

int n = 0;

for (; n < IMAGE_SIZEOF_SHORT_NAME && section->Name[n]; n++)
section_name[n] = section->Name[n];

section_name[n] = '\0';
strncpy(section_name, (char*) section->Name, IMAGE_SIZEOF_SHORT_NAME);
section_name[IMAGE_SIZEOF_SHORT_NAME] = '\0';

set_string(
section_name,
Expand Down

0 comments on commit 14dbf62

Please sign in to comment.