public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] resolv: use proper bound in __gai_freemem
@ 2023-09-05 15:27 Peter Edwards
  2023-09-07  8:46 ` Florian Weimer
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Edwards @ 2023-09-05 15:27 UTC (permalink / raw)
  To: libc-alpha; +Cc: Peter Edwards

__gai_freemem participates in the __libc_freeres mechanism to clean up
things at exit when requested by debugging/heap-checking tools such as
valgrind

The "pool" in gai_misc.c has valid data over the range [0, pool_size),
but the allocation stretches as far as pool_max_size. The elements
between pool_size and pool_max_size are uninitialized - so, use
pool_size as the iteration limit when free'ing data from pool, not
pool_max_size.
---
 resolv/gai_misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/resolv/gai_misc.c b/resolv/gai_misc.c
index 9e3b1d29b7..0c0ae741f9 100644
--- a/resolv/gai_misc.c
+++ b/resolv/gai_misc.c
@@ -442,7 +442,7 @@ __gai_freemem (void)
 {
   size_t row;
 
-  for (row = 0; row < pool_max_size; ++row)
+  for (row = 0; row < pool_size; ++row)
     free (pool[row]);
 
   free (pool);
-- 
2.42.0.111.gd814540bb7


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

end of thread, other threads:[~2023-09-07  8:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-05 15:27 [PATCH] resolv: use proper bound in __gai_freemem Peter Edwards
2023-09-07  8:46 ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).