From d338bb46b8c03c33e6182e725911af6d778bcf00 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 27 Mar 2015 12:57:17 +0100 Subject: ncache: Fix sss_ncache_reset_permanent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There was an off-by-one error in sss_ncache_reset_permanent that prevented the reset from working. Reviewed-by: Lukáš Slebodník --- src/responder/common/negcache.c | 2 +- src/tests/cmocka/test_negcache.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/responder/common/negcache.c b/src/responder/common/negcache.c index 88dd18fa5..04c9a53f5 100644 --- a/src/responder/common/negcache.c +++ b/src/responder/common/negcache.c @@ -556,7 +556,7 @@ static int delete_permanent(struct tdb_context *tdb, char *ep; if (strncmp((char *)key.dptr, - NC_ENTRY_PREFIX, sizeof(NC_ENTRY_PREFIX)) != 0) { + NC_ENTRY_PREFIX, sizeof(NC_ENTRY_PREFIX) - 1) != 0) { /* not interested in this key */ return 0; } diff --git a/src/tests/cmocka/test_negcache.c b/src/tests/cmocka/test_negcache.c index f98081337..4502c0294 100644 --- a/src/tests/cmocka/test_negcache.c +++ b/src/tests/cmocka/test_negcache.c @@ -563,10 +563,21 @@ static void test_sss_ncache_reset_permanent(void **state) { int ret; struct test_state *ts; + const bool permanent = true; ts = talloc_get_type_abort(*state, struct test_state); + + ret = sss_ncache_set_uid(ts->ctx, permanent, 0); + assert_int_equal(ret, EOK); + + ret = sss_ncache_check_uid(ts->ctx, 0, 0); + assert_int_equal(ret, EEXIST); + ret = sss_ncache_reset_permanent(ts->ctx); assert_int_equal(ret, EOK); + + ret = sss_ncache_check_uid(ts->ctx, 0, 0); + assert_int_equal(ret, ENOENT); } static void test_sss_ncache_prepopulate(void **state) -- cgit