From 7e70c88277d7ae3f7b953af51da4e97917923fda Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Sat, 5 Mar 2016 18:57:22 +0100 Subject: [PATCH] TOOLS: Prevent dereference of null pointer VAR_CHECK is called with (var, EOK, ...) EOK would be returned in case of "var != EOK" and output argument _attrs would not be initialized. Therefore there could be dereference of null pointer after calling function usermod_build_attrs. --- src/tools/sss_sync_ops.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tools/sss_sync_ops.c b/src/tools/sss_sync_ops.c index 5468929b691c6539cdf55f59be3560412e398f21..b2bbe4c74f5969b097af0f82bb00ca7ec35a596c 100644 --- a/src/tools/sss_sync_ops.c +++ b/src/tools/sss_sync_ops.c @@ -40,7 +40,7 @@ #define VAR_CHECK(var, val, attr, msg) do { \ if (var != (val)) { \ DEBUG(SSSDBG_CRIT_FAILURE, msg" attribute: %s\n", attr); \ - return val; \ + goto done; \ } \ } while(0) @@ -266,7 +266,12 @@ static int usermod_build_attrs(TALLOC_CTX *mem_ctx, } *_attrs = attrs; - return EOK; + ret = EOK; +done: + if (ret != EOK) { + talloc_free(attrs); + } + return ret; } /* -- 2.7.2