public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [edk2-libc Patch 0/1] edk2-libc/StdLib fix uninitialized global variable
@ 2023-07-21 15:26 Jayaprakash, N
  0 siblings, 0 replies; 4+ messages in thread
From: Jayaprakash, N @ 2023-07-21 15:26 UTC (permalink / raw)
  To: devel; +Cc: Jayaprakash N

This patch has fix for un-initialized global variable in the edk2-libc repos
StdLib/BsdSocketLib.

Jayaprakash N (1):
  edk2-libc/StdLib: Uninitialized global variable

 StdLib/BsdSocketLib/res_init.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

-- 
2.40.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107125): https://edk2.groups.io/g/devel/message/107125
Mute This Topic: https://groups.io/mt/100278657/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [edk2-devel] [edk2-libc Patch 0/1] edk2-libc/StdLib: Fix uninitialized global variable
@ 2023-07-25 16:07 Jayaprakash, N
  2023-07-25 16:07 ` [edk2-devel] [edk2-libc Patch 1/1] " Jayaprakash, N
  0 siblings, 1 reply; 4+ messages in thread
From: Jayaprakash, N @ 2023-07-25 16:07 UTC (permalink / raw)
  To: devel; +Cc: Jayaprakash N

This patch contains the fix for uninitialized global variable
in edk2-libc/StdLib/BsdSocketLib/res_init.c file.

Jayaprakash N (1):
  edk2-libc/StdLib: Fix uninitialized global variable

 StdLib/BsdSocketLib/res_init.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.40.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107251): https://edk2.groups.io/g/devel/message/107251
Mute This Topic: https://groups.io/mt/100353378/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix uninitialized global variable
  2023-07-25 16:07 [edk2-devel] [edk2-libc Patch 0/1] edk2-libc/StdLib: Fix uninitialized global variable Jayaprakash, N
@ 2023-07-25 16:07 ` Jayaprakash, N
  2023-07-26 11:33   ` Michael Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Jayaprakash, N @ 2023-07-25 16:07 UTC (permalink / raw)
  To: devel; +Cc: Jayaprakash N, Rebecca Cran, Michael D Kinney, Kloper Dimitry

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@bsdio.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jayaprakash N <n.jayaprakash@intel.com>
Signed-off-by: Kloper Dimitry <dimitry.kloper@intel.com>
---
 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..faf2b5e 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
+#endif
+    = {0}
+#endif
     ;
 
 
-- 
2.40.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107252): https://edk2.groups.io/g/devel/message/107252
Mute This Topic: https://groups.io/mt/100353380/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix uninitialized global variable
  2023-07-25 16:07 ` [edk2-devel] [edk2-libc Patch 1/1] " Jayaprakash, N
@ 2023-07-26 11:33   ` Michael Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Brown @ 2023-07-26 11:33 UTC (permalink / raw)
  To: devel, n.jayaprakash; +Cc: Rebecca Cran, Michael D Kinney, Kloper Dimitry

On 25/07/2023 17:07, Jayaprakash, N wrote:
> 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.
>   
>   struct __res_state _res
> -# if defined(__BIND_RES_TEXT)
> +#if defined(__BIND_RES_TEXT)
>       = { RES_TIMEOUT, }  /* Motorola, et al. */
> -# endif
> +#endif
> +    = {0}
> +#endif
>       ;

NAK.  This is very wrong.

Firstly, your patch introduces unnecessary whitespace changes and so is 
unnecessarily cumbersome to review.

Secondly, the patch creates an invalid "#if ... #endif ... #endif" 
combination.  I suspect that you meant to use "#else" in the middle.

Thirdly, and most importantly, the whole patch is entirely unnecessary. 
As a variable with static storage duration, if no explicit initializer 
is provided then the C language guarantees that the value will be 
initialized to zero anyway.

Thanks,

Michael



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107268): https://edk2.groups.io/g/devel/message/107268
Mute This Topic: https://groups.io/mt/100353380/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-26 11:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-25 16:07 [edk2-devel] [edk2-libc Patch 0/1] edk2-libc/StdLib: Fix uninitialized global variable Jayaprakash, N
2023-07-25 16:07 ` [edk2-devel] [edk2-libc Patch 1/1] " Jayaprakash, N
2023-07-26 11:33   ` Michael Brown
  -- strict thread matches above, loose matches on Subject: below --
2023-07-21 15:26 [edk2-devel] [edk2-libc Patch 0/1] edk2-libc/StdLib fix " Jayaprakash, N

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox