[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] tools/xenstore: fix hashtable_expand() zeroing new area



commit b977929d3646a390f1a7b4540fcd7a36aa59ff14
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Fri Jan 21 16:21:19 2022 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri Jan 21 15:34:45 2022 +0000

    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 <jgross@xxxxxxxx>
    Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 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);
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.