From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1afWOu-0003SH-PC for mharc-grub-devel@gnu.org; Mon, 14 Mar 2016 13:35:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afWOr-0003Oj-AW for grub-devel@gnu.org; Mon, 14 Mar 2016 13:35:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afWOn-0008GT-9K for grub-devel@gnu.org; Mon, 14 Mar 2016 13:35:25 -0400 Received: from mail-lb0-x22b.google.com ([2a00:1450:4010:c04::22b]:34730) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afWOm-0008FK-PF for grub-devel@gnu.org; Mon, 14 Mar 2016 13:35:21 -0400 Received: by mail-lb0-x22b.google.com with SMTP id k12so16173983lbb.1 for ; Mon, 14 Mar 2016 10:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=VqQI9A2skgfwF431bvrCfWusLAOQFaj2J+3dgT1Zo2o=; b=wRDvsFHZb30qzouvrtjZjJFhKvu5lVVJCw67D14CdskGdTo7u0xdW8maiWljPvAT/P JZMnbTywdKtn/p3uATJVCxeWleBx9dPWNK6WmYb7K/1STEEZYqpB02YLiJEso3T3o7v4 q25/XsYUyZ53qHAjE/XcPzXTqM9XmPq60dCOJ6DdtVFhAZigvFGbHLn7yT/qt2MhkOeG AODE2g56uYbjHjyuDOMvNC1V5RZ8tdhUTWYnWcdfqxxXAZjdMxExLF5fdEQCNqUwH4QZ WMX2v6LfRf6CaBNaFmx5dtxV1C8cbY3U0Q8PbScDhkljLgZ88brrAgNVToD60F6ehsrX MaCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=VqQI9A2skgfwF431bvrCfWusLAOQFaj2J+3dgT1Zo2o=; b=fN68ygvs5CPLc7SwL6jgA/nlvdtzdAjTCi1Wnrc4dnH2iKD4vdSOmCsisEgi6vvB2l JyWWOVXXUiFSxshI200GW47yEKNdCsmUGXG+hJcOZCuFm+t8NYor39fL5DzM1f7wgmSv 4sG86ocXIAP495/GNsLJyRf8wMfy7WZ8Io1YuWmF9PztDtdyQYlBWIXopmUFtR61u2sN b/5ytk/rIRldpS92eT+2moBRdXOZoOBZIh+o+ifMu7vX3zt1pzkQcfN6pYuEex8nq899 kjEtWa7X2HRcgZZumQtvdoUE8dKd2B+7/jCMh4gJpM1fYcbnwRP+Xtjxzs/+h4F4wybX z1Ag== X-Gm-Message-State: AD7BkJKltncwWe0+e40fodZGuuYypfIk1Ww+8rPrRGpx2aLp7R7l4TMDMUVqvNdOCneyMw== X-Received: by 10.112.139.202 with SMTP id ra10mr8043262lbb.41.1457976919894; Mon, 14 Mar 2016 10:35:19 -0700 (PDT) Received: from [192.168.1.42] (ppp109-252-76-159.pppoe.spdop.ru. [109.252.76.159]) by smtp.gmail.com with ESMTPSA id l129sm3718667lfl.18.2016.03.14.10.35.18 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 14 Mar 2016 10:35:18 -0700 (PDT) Subject: Re: 2.02-beta3 remove attempt to free stack space and initialize variable before possible use To: The development of GNU GRUB , aluft@lifesize.com References: <37E3C737-047D-4F32-9A09-CC2F154C45DF@lifesize.com> From: Andrei Borzenkov X-Enigmail-Draft-Status: N1110 Message-ID: <56E6F655.8090207@gmail.com> Date: Mon, 14 Mar 2016 20:35:17 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <37E3C737-047D-4F32-9A09-CC2F154C45DF@lifesize.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c04::22b X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Mar 2016 17:35:26 -0000 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?