From: Ken Raeburn Date: Thu, 1 Mar 2007 02:19:41 +0000 (+0000) Subject: valgrind detects uninitialized (but really unused) bytes in 'queue' X-Git-Tag: krb5-1.7-alpha1~1276 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bb351b78a590a4a94c1e76bd0809d0961832c072;p=krb5.git valgrind detects uninitialized (but really unused) bytes in 'queue' The gsstest program exports a GSSAPI security context to a blob in memory, writes that memory to a file, and reads it back to use it. Under valgrind, the writing phase triggers a warning about uninitialized storage. The "queue" structure as implemented in generic/util_ordering.c holds an array of values, some of which may never be initialized. As far as I can tell, those uninitialized values are never used before being initialized, either, but valgrind doesn't know that. This patch zaps the structure contents (including the array) before using the queue object. ticket: new target_version: 1.6.1 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19196 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/gssapi/generic/util_ordering.c b/src/lib/gssapi/generic/util_ordering.c index f7cf66678..218462bb0 100644 --- a/src/lib/gssapi/generic/util_ordering.c +++ b/src/lib/gssapi/generic/util_ordering.c @@ -96,6 +96,12 @@ g_order_init(void **vqueue, gssint_uint64 seqnum, if ((q = (queue *) malloc(sizeof(queue))) == NULL) return(ENOMEM); + /* This stops valgrind from complaining about writing uninitialized + data if the caller exports the context and writes it to a file. + We don't actually use those bytes at all, but valgrind still + complains. */ + memset(q, 0xfe, sizeof(*q)); + q->do_replay = do_replay; q->do_sequence = do_sequence; q->mask = wide_nums ? ~(gssint_uint64)0 : 0xffffffffUL;