[PATCH 2/2] Initialize all of datahead structure in nscd [BZ #16791]

Siddhesh Poyarekar siddhesh@redhat.com
Tue Apr 1 17:00:00 GMT 2014


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(+)

diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h
index c069bf6..663fcc5 100644
--- a/nscd/nscd-client.h
+++ b/nscd/nscd-client.h
@@ -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.  */
-- 
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20140401/f794dee7/attachment.sig>


More information about the Libc-alpha mailing list