From 64b6bbf9614a2032ff1d1773ea32b30360775d6c Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Wed, 13 Apr 2016 21:44:37 +0200 Subject: [PATCH 3/3] SYSDB_SUDO: Remove useless test The function sysdb_search_custom cannot return EOK and together set output argument count to zero. This case is already handled in function sysdb_search_entry which is used inside sysdb_search_custom. Such useless test can just cause read of unitialized variable in case of other errors returned from sysdb_search_custom. Error: UNINIT (CWE-457): [#def1] sssd-1.13.4/src/db/sysdb_sudo.c:678: var_decl: Declaring variable "count" without initializer. sssd-1.13.4/src/db/sysdb_sudo.c:698: uninit_use: Using uninitialized value "count". # 696| SUDORULE_SUBDIR, attrs, # 697| &count, &msgs); # 698|-> if (ret == ENOENT || count == 0) { # 699| DEBUG(SSSDBG_TRACE_FUNC, "No rules matched\n"); # 700| ret = EOK; --- src/db/sysdb_sudo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/db/sysdb_sudo.c b/src/db/sysdb_sudo.c index 76116abacb20219f0c1dcdde755e8268e10fd293..cdea5beed6e98330f4f6ea05720dbef530ab8071 100644 --- a/src/db/sysdb_sudo.c +++ b/src/db/sysdb_sudo.c @@ -695,7 +695,7 @@ sysdb_sudo_purge_byfilter(struct sss_domain_info *domain, ret = sysdb_search_custom(tmp_ctx, domain, filter, SUDORULE_SUBDIR, attrs, &count, &msgs); - if (ret == ENOENT || count == 0) { + if (ret == ENOENT) { DEBUG(SSSDBG_TRACE_FUNC, "No rules matched\n"); ret = EOK; goto done; -- 2.7.3