From 14dbf62b132c1d7294fa3b4a535d5fec3f6246b9 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Thu, 30 Jul 2015 19:39:05 +0200 Subject: [PATCH] Use strncpy as proposed by Hilko Bengen in PR #314 It does the same but is more compact and elegant. --- libyara/modules/pe.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libyara/modules/pe.c b/libyara/modules/pe.c index 9577e7fabb..4dcc13c332 100644 --- a/libyara/modules/pe.c +++ b/libyara/modules/pe.c @@ -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,