]> gitweb.ps.run Git - ps-cgit/commit
cache: don't leave cache_slot fields uninitialized
authorJohn Keeping <john@keeping.me.uk>
Sun, 12 Jan 2014 16:49:40 +0000 (16:49 +0000)
committerJason A. Donenfeld <Jason@zx2c4.com>
Sun, 12 Jan 2014 18:32:20 +0000 (19:32 +0100)
commit382ecf152e1bd9546f6c84ace71c62ca07f6648b
treeb3a66c0bbab90bd5bd4abf20647c5203061099a8
parent3eae406934b98ce78eff3a92cb410475d71095a3
cache: don't leave cache_slot fields uninitialized

Valgrind says:

==18344== Conditional jump or move depends on uninitialised value(s)
==18344==    at 0x406C83: open_slot (cache.c:63)
==18344==    by 0x407478: cache_ls (cache.c:403)
==18344==    by 0x404C9A: process_request (cgit.c:639)
==18344==    by 0x406BD2: fill_slot (cache.c:190)
==18344==    by 0x4071A0: cache_process (cache.c:284)
==18344==    by 0x404461: main (cgit.c:952)
==18344==  Uninitialised value was created by a stack allocation
==18344==    at 0x40738B: cache_ls (cache.c:375)

This is caused by the keylen field being used to calculate whether or
not a slot is matched.  We never then check the value of this and the
length of data read depends on the key length read from the file so this
isn't dangerous, but it's nice to avoid branching based on uninitialized
data.

Signed-off-by: John Keeping <john@keeping.me.uk>
cache.c