[Patch]: ld crash on i386/pe when linking with a dll that has no exports

Christopher Faylor cgf-use-the-mailinglist-please@sourceware.org
Wed Nov 25 17:24:00 GMT 2009


On Wed, Nov 25, 2009 at 10:20:54AM +0100, Tristan Gingold wrote:
>Hi,
>
>we got a crash when linking with a dll whose export directory is empty:
>...
>NumberOfRvaAndSizes	00000010
>
>The Data Directory
>Entry 0 00000000 00000000 Export Directory [.edata (or where ever we found it)]
>Entry 1 00016000 0000003c Import Directory [parts of .idata]
>...
>
>In fact there is no guard against such values in ld/pe-dll.c(pe_implied_import_dll) and this function
>assumes that the export directory entry is not empty if present.
>
>This patch fixes this crash.

Isn't this supposed to be handled by the

  if (num_entries < 1) /* No exports.  */
    return FALSE;

a few lines above it?

If this test is inadequate then it seems like num_entries isn't needed
and should be deleted.

cgf


>ld/
>2009-11-25  Tristan Gingold  <gingold@adacore.com>
>
>	* pe-dll.c (pe_implied_import_dll): Return early if there is no
>	export entries.
>
>*** ld/pe-dll.c	15 Nov 2009 07:52:42 -0000	1.123
>--- ld/pe-dll.c	25 Nov 2009 09:12:43 -0000
>***************
>*** 3001,3006 ****
>--- 3001,3010 ----
>    export_size = pe_get32 (dll, opthdr_ofs + 100);
>  #endif
>  
>+   /* No exports.  */
>+   if (export_size == 0)
>+     return FALSE;
>+ 
>    nsections = pe_get16 (dll, pe_header_offset + 4 + 2);
>    secptr = (pe_header_offset + 4 + 20 +
>  	    pe_get16 (dll, pe_header_offset + 4 + 16));
>
>



More information about the Binutils mailing list