From b977929d3646a390f1a7b4540fcd7a36aa59ff14 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 21 Jan 2022 16:21:19 +0100 Subject: [PATCH] tools/xenstore: fix hashtable_expand() zeroing new area 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 Reviewed-by: Anthony PERARD --- 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.30.2