|
@@ -458,6 +458,7 @@ static struct pe_section * process_section ( struct elf_file *elf,
|
458
|
458
|
struct pe_header *pe_header ) {
|
459
|
459
|
struct pe_section *new;
|
460
|
460
|
const char *name;
|
|
461
|
+ size_t name_len;
|
461
|
462
|
size_t section_memsz;
|
462
|
463
|
size_t section_filesz;
|
463
|
464
|
unsigned long code_start;
|
|
@@ -494,7 +495,10 @@ static struct pe_section * process_section ( struct elf_file *elf,
|
494
|
495
|
memset ( new, 0, sizeof ( *new ) + section_filesz );
|
495
|
496
|
|
496
|
497
|
/* Fill in section header details */
|
497
|
|
- strncpy ( ( char * ) new->hdr.Name, name, sizeof ( new->hdr.Name ) );
|
|
498
|
+ name_len = strlen ( name );
|
|
499
|
+ if ( name_len > sizeof ( new->hdr.Name ) )
|
|
500
|
+ name_len = sizeof ( new->hdr.Name );
|
|
501
|
+ memcpy ( new->hdr.Name, name, name_len );
|
498
|
502
|
new->hdr.Misc.VirtualSize = section_memsz;
|
499
|
503
|
new->hdr.VirtualAddress = shdr->sh_addr;
|
500
|
504
|
new->hdr.SizeOfRawData = section_filesz;
|