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 22322941577 for ; Fri, 21 Jul 2023 15:27:21 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=OGhXuam/igVnKmyc6NyXQsXRIOkJfDpwGni0uOQSH8k=; 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-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=1689953240; v=1; b=jkxQE3Xyl/b30mCOzq2INODOeodoHNB4JSDJmbCi9CcW/5BV71QgrqxO/j1/ZkudhVydwYA/ h9B0uIL7OSBNW4ueBD+NwcmAe1HlJ4GakIWXn8J3+wbLcvY6okHg5QM8H1tZPP1nTrvI/CARDgg KxKx/vYCj11OiN7IOWI+D5OI= X-Received: by 127.0.0.2 with SMTP id vW4FYY7687511x6RJ4E7ADkc; Fri, 21 Jul 2023 08:27:20 -0700 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web11.10027.1689953235531172144 for ; Fri, 21 Jul 2023 08:27:20 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10778"; a="357039125" X-IronPort-AV: E=Sophos;i="6.01,222,1684825200"; d="scan'208";a="357039125" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2023 08:27:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10778"; a="971468000" X-IronPort-AV: E=Sophos;i="6.01,222,1684825200"; d="scan'208";a="971468000" X-Received: from njayapra-mobl.gar.corp.intel.com ([10.213.73.65]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2023 08:27:17 -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 1/1] edk2-libc/StdLib: Uninitialized global variable Date: Fri, 21 Jul 2023 20:56:52 +0530 Message-Id: <20230721152652.1761-2-n.jayaprakash@intel.com> In-Reply-To: <20230721152652.1761-1-n.jayaprakash@intel.com> References: <20230721152652.1761-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: OdSflGfrinYucQs3jSA4HGqBx7686176AA= 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=jkxQE3Xy; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/StdLib/BsdSocketLib/res_init.c b/StdLib/BsdSocketLib/res_init.c index 613a76a..fbc53c5 100644 --- a/StdLib/BsdSocketLib/res_init.c +++ b/StdLib/BsdSocketLib/res_init.c @@ -121,11 +121,11 @@ 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 - ; - +#if defined(__BIND_RES_TEXT) + = { RES_TIMEOUT, }; /* Motorola, et al. */ +#else + = {0}; +#endif /* * Set up default settings. If the configuration file exist, the values -- 2.40.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107126): https://edk2.groups.io/g/devel/message/107126 Mute This Topic: https://groups.io/mt/100278658/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-