From 37a84285aeb497ed4909d16916bbf934af3f68b3 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Apr 10 2018 12:43:42 +0000 Subject: 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 --- diff --git a/src/responder/nss/nss_cmd.c b/src/responder/nss/nss_cmd.c index 956ee53..9f8479b 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) {