From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>, Wei Liu <wl@xen.org>,
Julien Grall <julien@xen.org>,
Anthony PERARD <anthony.perard@citrix.com>
Subject: [PATCH 2/3] tools/xenstore: fix hashtable_expand() zeroing new area
Date: Thu, 20 Jan 2022 13:02:35 +0100 [thread overview]
Message-ID: <20220120120236.13826-3-jgross@suse.com> (raw)
In-Reply-To: <20220120120236.13826-1-jgross@suse.com>
When realloc()ing the hashtable for expanding it, zero out all the new
bytes at the end of the table, not only one byte for each new element.
Fixes: 186f0e02a1c ("Added hashtable implementation")
Signed-off-by: Juergen Gross <jgross@suse.com>
---
This might be a backport candidate
---
tools/xenstore/hashtable.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/xenstore/hashtable.c b/tools/xenstore/hashtable.c
index 39fb3ed338..6ac336eff1 100644
--- a/tools/xenstore/hashtable.c
+++ b/tools/xenstore/hashtable.c
@@ -136,7 +136,8 @@ hashtable_expand(struct hashtable *h)
realloc(h->table, newsize * sizeof(struct entry *));
if (NULL == newtable) { (h->primeindex)--; return 0; }
h->table = newtable;
- memset(newtable[h->tablelength], 0, newsize - h->tablelength);
+ memset(newtable + h->tablelength, 0,
+ (newsize - h->tablelength) * sizeof(*newtable));
for (i = 0; i < h->tablelength; i++) {
for (pE = &(newtable[i]), e = *pE; e != NULL; e = *pE) {
index = indexFor(newsize,e->h);
--
2.31.1
next prev parent reply other threads:[~2022-01-20 12:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-20 12:02 [PATCH 0/3] tools/xenstore: simplify hashtable implementation Juergen Gross
2022-01-20 12:02 ` [PATCH 1/3] tools/xenstore: merge hashtable_private.h into hashtable.c Juergen Gross
2022-01-21 14:40 ` Anthony PERARD
2022-01-20 12:02 ` Juergen Gross [this message]
2022-01-21 14:55 ` [PATCH 2/3] tools/xenstore: fix hashtable_expand() zeroing new area Anthony PERARD
2022-01-20 12:02 ` [PATCH 3/3] tools/xenstore: drop DEFINE_HASHTABLE_* macros and usage intro Juergen Gross
2022-01-21 15:13 ` Anthony PERARD
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=20220120120236.13826-3-jgross@suse.com \
--to=jgross@suse.com \
--cc=anthony.perard@citrix.com \
--cc=julien@xen.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.