From: Andrei Borzenkov <arvidjaar@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>, aluft@lifesize.com
Subject: Re: 2.02-beta3 remove attempt to free stack space and initialize variable before possible use
Date: Mon, 14 Mar 2016 20:35:17 +0300 [thread overview]
Message-ID: <56E6F655.8090207@gmail.com> (raw)
In-Reply-To: <37E3C737-047D-4F32-9A09-CC2F154C45DF@lifesize.com>
14.03.2016 17:37, Aaron Luft пишет:
> 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
>
I cannot apply them due to whitespace changes.
>
>
> 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;
> }
>
Yes, this is one correct. Please resend as attached patch generated by
"git format-patch" with suitable commit message. Do not expand tabs when
editing.
> 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"));
>
Well ... it cannot really reach code where mdnobj is used if
grub_zfs_getmdnobj() fails but static analyzer may not know it.
How do you compile it? I cannot reproduce it using gcc 5.3.1 nor did it
fail previously. Do you use non-standard compiler flags?
next prev parent reply other threads:[~2016-03-14 17:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2016-03-14 21:21 ` Aaron Luft
2016-03-15 19:18 ` Andrei Borzenkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56E6F655.8090207@gmail.com \
--to=arvidjaar@gmail.com \
--cc=aluft@lifesize.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.