From: Peter Edwards <peadar@arista.com>
To: libc-alpha@sourceware.org
Cc: Peter Edwards <peadar@arista.com>
Subject: [PATCH] resolv: use proper bound in __gai_freemem
Date: Tue, 5 Sep 2023 16:27:02 +0100 [thread overview]
Message-ID: <20230905152702.619804-1-peadar@arista.com> (raw)
__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
next reply other threads:[~2023-09-05 15:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-05 15:27 Peter Edwards [this message]
2023-09-07 8:46 ` Florian Weimer
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-all 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=20230905152702.619804-1-peadar@arista.com \
--to=peadar@arista.com \
--cc=libc-alpha@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).