grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] bug fix for grub-pe2elf


From: Bean
Subject: [PATCH] bug fix for grub-pe2elf
Date: Sat, 11 Apr 2009 17:29:00 +0800

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]