grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* 2.02-beta3 remove attempt to free stack space and initialize variable before possible use
@ 2016-03-14 14:37 Aaron Luft
  2016-03-14 17:35 ` Andrei Borzenkov
  0 siblings, 1 reply; 4+ messages in thread
From: Aaron Luft @ 2016-03-14 14:37 UTC (permalink / raw)
  To: grub-devel@gnu.org

Please consider these improvements to 2.02-beta3.
1) Remove the variable "oldname" which is attempting to free stack space.
2) Initialize the value of mdnobj to silence the compiler warning

In function 'grub_free',
    inlined from 'grub_iso9660_iterate_dir' at grub-core/fs/iso9660.c:764:15:
grub-core/kern/emu/mm.c:53:3: error: attempt to free a non-heap object 'name' [-Werror=free-nonheap-object]
   free (ptr);
   ^
lto1: all warnings being treated as errors
lto-wrapper: fatal error: x86_64-linux-gnu-gcc-5.3.0 returned 1 exit status

grub-core/fs/zfs/zfsinfo.c: In function 'grub_cmd_zfs_bootfs':
grub-core/fs/zfs/zfsinfo.c:401:10: error: 'mdnobj' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu%s%s%s%s%s%s",
          ^
grub-core/fs/zfs/zfsinfo.c:355:17: note: 'mdnobj' was declared here
   grub_uint64_t mdnobj;
                 ^
lto1: all warnings being treated as errors



diff -Naur grub-2.02-beta3.orig/grub-core/fs/iso9660.c grub-2.02-beta3/grub-core/fs/iso9660.c
--- grub-2.02-beta3.orig/grub-core/fs/iso9660.c 2016-02-28 02:07:41.000000000 +0000
+++ grub-2.02-beta3/grub-core/fs/iso9660.c      2016-03-12 01:17:26.581112809 +0000
@@ -750,19 +750,15 @@

         if (dir->data->joliet && !ctx.filename)
           {
-            char *oldname, *semicolon;
+            char *semicolon;

-            oldname = name;
             ctx.filename = grub_iso9660_convert_string
-                  ((grub_uint8_t *) oldname, dirent.namelen >> 1);
+                  ((grub_uint8_t *) name, dirent.namelen >> 1);

            semicolon = grub_strrchr (ctx.filename, ';');
            if (semicolon)
              *semicolon = '\0';

-            if (ctx.filename_alloc)
-              grub_free (oldname);
-
             ctx.filename_alloc = 1;
           }

diff -Naur grub-2.02-beta3.orig/grub-core/fs/zfs/zfsinfo.c grub-2.02-beta3/grub-core/fs/zfs/zfsinfo.c
--- grub-2.02-beta3.orig/grub-core/fs/zfs/zfsinfo.c     2016-02-28 02:07:41.000000000 +0000
+++ grub-2.02-beta3/grub-core/fs/zfs/zfsinfo.c  2016-03-12 01:18:00.504961950 +0000
@@ -352,7 +352,7 @@
   char *fsname;
   char *bootfs;
   char *poolname;
-  grub_uint64_t mdnobj;
+  grub_uint64_t mdnobj = 0;

   if (argc < 1)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-15 19:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-14 14:37 2.02-beta3 remove attempt to free stack space and initialize variable before possible use Aaron Luft
2016-03-14 17:35 ` Andrei Borzenkov
2016-03-14 21:21   ` Aaron Luft
2016-03-15 19:18     ` Andrei Borzenkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).