From: Juergen Gross Date: Fri, 21 Jan 2022 15:21:19 +0000 (+0100) Subject: tools/xenstore: fix hashtable_expand() zeroing new area X-Git-Tag: archive/raspbian/4.17.0-1+rpi1^2~33^2~1125 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b977929d3646a390f1a7b4540fcd7a36aa59ff14;p=xen.git 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 --- 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);