[2/2] Initialize all of datahead structure in nscd [BZ #16791]
Commit Message
Hi,
The datahead structure has an unused padding field that remains
uninitialized. Valgrind prints out a warning for it on querying a
netgroups entry. This is harmless, but is a potential data leak since
it would result in writing out an uninitialized byte to the cache
file. Besides, this happens only when there is a cache miss, so we're
not adding computation to any fast path.
Tested on x86_64 to verify that the valgrind warning is gone with
netgroups.
Siddhesh
[BZ #16791]
* nscd/nscd-client.h (datahead_init_common): Initialize unused
field in datahead.
---
nscd/nscd-client.h | 2 ++
1 file changed, 2 insertions(+)
Comments
If you bzero before explicitly filling fields, does the compiler optimize
to only zeroing the one unused field? If so, that seems more futureproof.
@@ -243,6 +243,8 @@ datahead_init_common (struct datahead *head, nscd_ssize_t allocsize,
head->allocsize = allocsize;
head->recsize = recsize;
head->usable = true;
+ /* Initialize so that we don't write out a junk byte to the cache. */
+ head->unused = 0;
head->ttl = ttl;
/* Compute the timeout time. */