From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id F3165D801E7 for ; Fri, 21 Jul 2023 15:48:06 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=m4Fzx0faLoZWOe4UcQlb1PcoEYFVmKjOhxNP8+Abq5g=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-IronPort-AV:X-IronPort-AV:X-Received:X-ExtLoop1:X-IronPort-AV:X-Received:From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:X-Gm-Message-State:Content-Transfer-Encoding; s=20140610; t=1689954485; v=1; b=bKjjGR435QLP3wXpAv8QtLXhWsAxY5X1hecyen+kcT3pPTVuZmCr0n8bnkUAKZf1mOtchJF8 KHBOm1Cw7wvSkLQPt7yzrksMpC9Ugw3yrPM4W8zt3h+FO/WEy8/JAwWcDLbhb5jnPzch8z0qMkZ IDVCBvpqjFXmycVF69Pmn2NQ= X-Received: by 127.0.0.2 with SMTP id T68zYY7687511xpVIgkXlHZi; Fri, 21 Jul 2023 08:48:05 -0700 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.10490.1689954481643648028 for ; Fri, 21 Jul 2023 08:48:05 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10778"; a="357043433" X-IronPort-AV: E=Sophos;i="6.01,222,1684825200"; d="scan'208";a="357043433" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2023 08:48:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="868275252" X-Received: from njayapra-mobl.gar.corp.intel.com ([10.213.73.65]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2023 08:48:03 -0700 From: "Jayaprakash, N" To: devel@edk2.groups.io Cc: Jayaprakash N , Rebecca Cran , Michael D Kinney , Kloper Dimitry Subject: [edk2-devel] [edk2-libc Patch v2 1/1] edk2-libc/StdLib: Uninitialized global variable Date: Fri, 21 Jul 2023 21:17:52 +0530 Message-Id: <20230721154752.1871-2-n.jayaprakash@intel.com> In-Reply-To: <20230721154752.1871-1-n.jayaprakash@intel.com> References: <20230721154752.1871-1-n.jayaprakash@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,n.jayaprakash@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 675rR7AFZYdmfxvzKluaPqpyx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=bKjjGR43; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none) REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4506 res_init() is called from different places in sockets library. It depends on global _res variable containing a state. The problem is that if __BIND_RES_TEXT macro is not defined, _res is not initialized. Depending on compiler and build optimization this can fill the variable with garbage that is later used by res_init(). Fix is trivial - explicitly initialize _res Cc: Rebecca Cran Cc: Michael D Kinney Co-authored-by: Kloper Dimitry Signed-off-by: Jayaprakash N --- StdLib/BsdSocketLib/res_init.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/StdLib/BsdSocketLib/res_init.c b/StdLib/BsdSocketLib/res_init.c index 613a76a..6421d9a 100644 --- a/StdLib/BsdSocketLib/res_init.c +++ b/StdLib/BsdSocketLib/res_init.c @@ -122,9 +122,10 @@ static u_int32_t net_mask __P((struct in_addr)); struct __res_state _res # if defined(__BIND_RES_TEXT) - = { RES_TIMEOUT, } /* Motorola, et al. */ -# endif - ; + = { RES_TIMEOUT, }; /* Motorola, et al. */ +#else + = {0}; +#endif /* -- 2.40.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107130): https://edk2.groups.io/g/devel/message/107130 Mute This Topic: https://groups.io/mt/100279095/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-