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

Re: [PATCH v2 11/18] tools/xenstore: drop use of tdb



Hi Juergen,

On 10/07/2023 07:59, Juergen Gross wrote:
-       return (struct xs_tdb_record_hdr *)data.dptr;
+       *size = sizeof(*hdr) + hdr->num_perms * sizeof(hdr->perms[0]) +
+               hdr->datalen + hdr->childlen;
+
+       p = talloc_size(NULL, *size);
+       if (!p) {
+               errno = ENOMEM;
+               return NULL;
+       }
+
+       trace_tdb("read %s size %zu\n", db_name, *size + strlen(db_name));
+
+       /* Return a copy, avoiding a potential modification in the DB. */
+       memcpy(p, hdr, *size);

The talloc_size() + memcpy() seems to be an open-coded version of talloc_memdup(). Can you use it?

The rest looks good to me.

Cheers,

--
Julien Grall



 


Rackspace

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