public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jayaprakash, N" <n.jayaprakash@intel.com>
To: devel@edk2.groups.io
Cc: Jayaprakash N <n.jayaprakash@intel.com>,
	Rebecca Cran <rebecca@nuviainc.com>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Kloper, Dimitry <dimitry.kloper@intel.com>
Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Uninitialized global variable
Date: Fri, 21 Jul 2023 20:56:52 +0530	[thread overview]
Message-ID: <20230721152652.1761-2-n.jayaprakash@intel.com> (raw)
In-Reply-To: <20230721152652.1761-1-n.jayaprakash@intel.com>

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 <rebecca@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Co-authored-by: Kloper, Dimitry <dimitry.kloper@intel.com>
Signed-off-by: Jayaprakash N <n.jayaprakash@intel.com>
---
 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]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2023-07-21 15:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 15:26 [edk2-devel] [edk2-libc Patch 0/1] edk2-libc/StdLib fix uninitialized global variable Jayaprakash, N
2023-07-21 15:26 ` Jayaprakash, N [this message]
2023-07-21 15:33   ` [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Uninitialized " Michael D Kinney
2023-07-21 15:52     ` Jayaprakash, N
     [not found]     ` <1773ECE2212EEB11.21241@groups.io>
2023-07-21 16:22       ` Jayaprakash, N

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230721152652.1761-2-n.jayaprakash@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox