From 29f9df0162096d0e3ec4e85c1f1b5ce87062aa64 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Thu, 15 Mar 2018 12:43:34 +0100 Subject: [PATCH] nss: initialize nss_enum_index in nss_setnetgrent() setnetgrent() is the first call when looking up a netgroup and sets the netgroup name for upcoming getnetgrent() and endnetgrent() calls. Currently the state is reset by calling endnetgrent() but it would be more robust to unconditionally reset the state in setnetgrent() as well in case calling endnetgrent() was forgotten. Related to https://pagure.io/SSSD/sssd/issue/3679 Reviewed-by: Jakub Hrozek (cherry picked from commit 37a84285aeb497ed4909d16916bbf934af3f68b3) --- src/responder/nss/nss_cmd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/responder/nss/nss_cmd.c b/src/responder/nss/nss_cmd.c index 956ee53cb..9f8479b7b 100644 --- a/src/responder/nss/nss_cmd.c +++ b/src/responder/nss/nss_cmd.c @@ -756,6 +756,9 @@ static errno_t nss_setnetgrent(struct cli_ctx *cli_ctx, goto done; } + state_ctx->netgrent.domain = 0; + state_ctx->netgrent.result = 0; + talloc_zfree(state_ctx->netgroup); state_ctx->netgroup = talloc_strdup(state_ctx, netgroup); if (state_ctx->netgroup == NULL) { -- 2.14.3