From 382ecf152e1bd9546f6c84ace71c62ca07f6648b Mon Sep 17 00:00:00 2001 From: John Keeping Date: Sun, 12 Jan 2014 16:49:40 +0000 Subject: 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 --- cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cache.c b/cache.c index d339435..fa83ddc 100644 --- a/cache.c +++ b/cache.c @@ -376,7 +376,7 @@ int cache_ls(const char *path) DIR *dir; struct dirent *ent; int err = 0; - struct cache_slot slot; + struct cache_slot slot = { 0 }; struct strbuf fullname = STRBUF_INIT; size_t prefixlen; -- cgit 1.4.1 ='/aoc/diff/2016/input/day12.txt?id=8fa601d965a75cca5ca203c308c5af9a5cf0c66a&follow=1'>diff homepage
Commit message (Collapse)Author
2017-12-03Day 3, clean upJune McEnroe
2017-12-03Day 3June McEnroe
This is fucking awful and I'm angry.
2017-12-02Day 2, part 2June McEnroe
2017-12-02Day 2June McEnroe
2017-12-01Day 1, part 2June McEnroe
2017-12-01Day 1June McEnroe
2017-11-27Move to 2016 directoryJune McEnroe