Hi,

When symbol name is 8 or less, pe store it as short name, which is not
necessary null-terminated. This patch take that into account and
append a null character at the end.

diff --git a/util/grub-pe2elf.c b/util/grub-pe2elf.c
index d703d33..a2504d2 100644
--- a/util/grub-pe2elf.c
+++ b/util/grub-pe2elf.c
@@ -344,10 +344,17 @@ write_symbol_table (FILE* fp, char *image,
         }
       else
         {
+         char short_name[9];
           char *name;

-          name = ((pe_symtab->long_name[0]) ? pe_symtab->short_name :
-                  pe_strtab + pe_symtab->long_name[1]);
+         if (pe_symtab->long_name[0])
+           {
+             strncpy (short_name, pe_symtab->short_name, 8);
+             short_name[8] = 0;
+             name = short_name;
+           }
+         else
+           name = pe_strtab + pe_symtab->long_name[1];

           if ((strcmp (name, "_grub_mod_init")) &&
               (strcmp (name, "_grub_mod_fini")) &&


-- 
Bean


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to