From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nUIH2-00037j-2W for mharc-grub-devel@gnu.org; Tue, 15 Mar 2022 21:16:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUIH0-00035J-IO for grub-devel@gnu.org; Tue, 15 Mar 2022 21:16:22 -0400 Received: from [2607:f8b0:4864:20::72a] (port=44577 helo=mail-qk1-x72a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUIGy-0006GZ-73 for grub-devel@gnu.org; Tue, 15 Mar 2022 21:16:22 -0400 Received: by mail-qk1-x72a.google.com with SMTP id b189so809901qkf.11 for ; Tue, 15 Mar 2022 18:16:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=qveQQw9+JRU9bvHrLAF6xzkCtp0Zz81QXqdp63i/tHY=; b=w/XSnE7FNeC0WNzu8VskDIiurXyR0MT5okB1CVdBvd6ap6oWtzd9CuukebFqkCzaL+ 1EtF+te5yDnHR+AzdXt5z1DXQh8x8lzxONqShvTuhKLKWZk2YcK6H8GsYm4U5KESTNU6 5sPAcYA10MLAhSAikwotFEo0bg0ET7+jFUBpZD966oat1AHwFHdDbsX55Gk+zcy/DqTS Z1p+uN7FlZwwupaRTBDv+wrX5eP9hjcK4mrCCiuI2kHxmDWyRmmrEXtC2tpgYUIQS4M2 zW4RsqbL3B441gQMnrd0oeh0erS6g91or9SXtyUwdbQg6e70xFnBcjeZF5BQfQ8POygl W35g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=qveQQw9+JRU9bvHrLAF6xzkCtp0Zz81QXqdp63i/tHY=; b=3J7W2dUwupayoZBuTJQZZ+PifxUU+QiICVP5tIbF4NYX50zP8o0Yklt68AuKKJ4sdq Fgz+SfQtrjXmAMEHkHHdedWvFynsXFBC/GLPs7Co5KOnJg5a2spGzwCSKdZ3YQCHJTt/ e5XuxnrqeCLqqB9mMl/aptK2Uqg+CLLOozMdCahy9gs+jUFx9GNES5FCcaZJgmxtptFf nhvitzLlfFECuX1rp70T8deaT09rGHn0XX+COA4UwGStCgMKwKU58s2CYcEvKRKpgrrt BlJDEMVaf8rW/eexspBhZDP5jS06m3iS1WMyJrdGbuK/DHBVvREepTh20QljdvJILh2q gvIw== X-Gm-Message-State: AOAM531S/UM9P/maZkPvV9el1psls3NOhAOacAfuZMjkL9gjYhAZYR1I 5J0cc19wdTnPCXak7HLzVkGUow== X-Google-Smtp-Source: ABdhPJwjDpAbWcl251pbVYr2vyh0M3Cbmi43+8BQfV8nvACDyu+lS5t65623rLlJ8WxbT3J2GU9ZxA== X-Received: by 2002:a05:620a:40c2:b0:67d:aede:28c8 with SMTP id g2-20020a05620a40c200b0067daede28c8mr10626335qko.318.1647393373605; Tue, 15 Mar 2022 18:16:13 -0700 (PDT) Received: from crass-HP-ZBook-15-G2 (51-15-0-88.rev.poneytelecom.eu. [51.15.0.88]) by smtp.gmail.com with ESMTPSA id d19-20020a05622a05d300b002e1e720ddcesm491788qtb.4.2022.03.15.18.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 18:16:13 -0700 (PDT) Date: Tue, 15 Mar 2022 20:16:01 -0500 From: Glenn Washburn To: Alec Brown Cc: The development of GNU GRUB , daniel.kiper@oracle.com, darren.kenny@oracle.com Subject: Re: [PATCH 5/7] grub-core/net/net.c: Fix uninitialized scalar variable Message-ID: <20220315201601.2b2828a4@crass-HP-ZBook-15-G2> In-Reply-To: <1647375849-24164-6-git-send-email-alec.r.brown@oracle.com> References: <1647375849-24164-1-git-send-email-alec.r.brown@oracle.com> <1647375849-24164-6-git-send-email-alec.r.brown@oracle.com> Reply-To: development@efficientek.com X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::72a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=development@efficientek.com; helo=mail-qk1-x72a.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Mar 2022 01:16:22 -0000 On Tue, 15 Mar 2022 16:24:07 -0400 Alec Brown wrote: > In the function grub_net_ipv6_get_link_local(), grub_net_network_level_address_t > addr is called but isn't being initialized. To prevent contents of this > structure from being filled with junk data from the stack, we can initialize it > to 0 by setting addr to {}; > > Fixes: CID 375033 > > Signed-off-by: Alec Brown > --- > grub-core/net/net.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/grub-core/net/net.c b/grub-core/net/net.c > index 4d3eb5c1a..4e93365a7 100644 > --- a/grub-core/net/net.c > +++ b/grub-core/net/net.c > @@ -287,7 +287,7 @@ grub_net_ipv6_get_link_local (struct grub_net_card *card, > struct grub_net_network_level_interface *inf; > char *name; > char *ptr; > - grub_net_network_level_address_t addr; > + grub_net_network_level_address_t addr = {}; > > addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; > addr.ipv6[0] = grub_cpu_to_be64_compile_time (0xfe80ULL << 48); This seems not quite necessary. The local "addr" is initialized just below its initialization, so "junk" data doesn't matter. Only the "option" member is not initialized, so we could just add another line to initialize that. The "{}" syntax seems to not be used much either, "{0}" being preferred, but also not used much. I think I remember Vladimir saying that GRUB doesn't use initializers, but there are some in the code, so perhaps this isn't a thing anymore. Another option, which would be my preference, would be to move the 3 lines below the declaraction of "addr" into the initializer and use C99's designated initializer, so something like: grub_net_network_level_address_t addr = { .type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6, .ipv6 = { grub_cpu_to_be64_compile_time (0xfe80ULL << 48), grub_net_ipv6_get_id (hwaddr) } }; There is precedent for using function calls in initializers (net/dns.c:453), but its also rare. Daniel, do you have a preference here? Glenn