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 1CD64AC1602 for ; Wed, 26 Jul 2023 15:39:01 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=VQNM+/dh6r5ywgGRvMDe7B4YiDfw9E4mH5OhAuUa9S4=; 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=1690385940; v=1; b=Zq3qXDWngtO/bLaAU+SOeVnStsWtZtHSCtlOrJHHh+wUbmp5RgRrvVVgleng2MKGRQIYafjY IHKlelfF8h5Ya7qYA+ZILGN1EAcAkm2bScZJFslc+rLbDRL7FnoyqahOUlEKfUKC0S7Ovnad0je sCCsVnfLIZuVtTGylMx4Qbm8= X-Received: by 127.0.0.2 with SMTP id N3anYY7687511x4Mtk6SiwqP; Wed, 26 Jul 2023 08:39:00 -0700 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.14319.1690385936837922447 for ; Wed, 26 Jul 2023 08:39:00 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10783"; a="371663993" X-IronPort-AV: E=Sophos;i="6.01,232,1684825200"; d="scan'208";a="371663993" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2023 08:39:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10783"; a="816734826" X-IronPort-AV: E=Sophos;i="6.01,232,1684825200"; d="scan'208";a="816734826" X-Received: from njayapra-mobl.gar.corp.intel.com ([10.213.71.85]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2023 08:38:57 -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: Fix uninitialized global variable Date: Wed, 26 Jul 2023 21:08:48 +0530 Message-Id: <20230726153848.1584-2-n.jayaprakash@intel.com> In-Reply-To: <20230726153848.1584-1-n.jayaprakash@intel.com> References: <20230726153848.1584-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: xcrVFR2hfRH3ERjWQExWoUmEx7686176AA= 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=Zq3qXDWn; 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 Cc: Jayaprakash N Signed-off-by: Kloper Dimitry --- StdLib/BsdSocketLib/res_init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/StdLib/BsdSocketLib/res_init.c b/StdLib/BsdSocketLib/res_init.c index 613a76a..9df7d4f 100644 --- a/StdLib/BsdSocketLib/res_init.c +++ b/StdLib/BsdSocketLib/res_init.c @@ -121,9 +121,11 @@ static u_int32_t net_mask __P((struct in_addr)); */ struct __res_state _res -# if defined(__BIND_RES_TEXT) +#if defined(__BIND_RES_TEXT) = { RES_TIMEOUT, } /* Motorola, et al. */ -# endif +#else + = {0} +#endif ; -- 2.40.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107273): https://edk2.groups.io/g/devel/message/107273 Mute This Topic: https://groups.io/mt/100373041/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-