Subject: Re: bug#20264: [PATCH] fix: w32_executable_type() causes a segmentation fault

From: Koichi Arakawa <[email-masked]>
Date: Mon, 06 Apr 2015 18:48:11 +0900(東京 (標準時))

Eli Zaretskii <[email-masked]> wrote:
>>                for ( ; imports->Name; imports++)
>>                  {
>>                    char * dllname = RVA_TO_PTR (imports->Name, section,
>>                                                 executable);
>>  
>> +                  if (imports->Name < base || dllname >= base + real_size)
>> +                    break;
>> +
> 
> Shouldn't that "break" be "continue" instead?  IOW, shouldn't we try
> all the other entries in the DLL import list?

I apologize insufficient research. The *illegal* dllname actually
points to another section. So the previous patch is wrong and it
should be as follows.

diff --git a/src/w32proc.c b/src/w32proc.c
index 7d982f8..5ae55ff 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1625,6 +1625,7 @@ w32_executable_type (char * filename,
 
               for ( ; imports->Name; imports++)
                 {
+                  section = rva_to_section (imports->Name, nt_header);
                   char * dllname = RVA_TO_PTR (imports->Name, section,
                                                executable);
 
-- 
Koichi Arakawa