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