From 1e2f20f89b1b699e569dfecb7cba98ec8f6fc936 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 956ee53cb88dd24faaa95ac39c8d9540af66cfb2..9f8479b7b350823ee81b5af15199e0dda9acda8b 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.17.0