Commit 37a8428 nss: initialize nss_enum_index in nss_setnetgrent()

1 file Authored by sbose 4 months ago , Committed by jhrozek 4 months ago ,
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 <jhrozek@redhat.com>

    
 1 @@ -756,6 +756,9 @@
 2           goto done;
 3       }
 4   
 5 +     state_ctx->netgrent.domain = 0;
 6 +     state_ctx->netgrent.result = 0;
 7 + 
 8       talloc_zfree(state_ctx->netgroup);
 9       state_ctx->netgroup = talloc_strdup(state_ctx, netgroup);
10       if (state_ctx->netgroup == NULL) {