From 87c80bfba583eadc087810d17aa631ef4e405efc Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Mon, 1 Jul 2019 14:37:24 +0100 Subject: [PATCH] Fix a double free in the List functions The code was set up so that it would free the individual items and the data in `freeListData`, but there was already a Go `defer` to free the data item, resulting in a double free. Remove the `free` in `freeListData` and leave the original one. In addition, move the `defer` for freeing the list data before the error check, so that the data is also free in the error case. This just removes a minor leak. This vulnerability was discovered by: Jasiel Spelman of Trend Micro Zero Day Initiative and Trend Micro Team Nebula Signed-off-by: Justin Cormack --- osxkeychain/osxkeychain_darwin.c | 1 - osxkeychain/osxkeychain_darwin.go | 5 ++--- secretservice/secretservice_linux.c | 1 - secretservice/secretservice_linux.go | 4 ++-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/osxkeychain/osxkeychain_darwin.c b/osxkeychain/osxkeychain_darwin.c index f84d61ee..845012bd 100644 --- a/osxkeychain/osxkeychain_darwin.c +++ b/osxkeychain/osxkeychain_darwin.c @@ -224,5 +224,4 @@ void freeListData(char *** data, unsigned int length) { for(int i=0; i