>From a448c2305ab672fbb1cfaeb66b080564268dea3a Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Mon Aug 18 17:40:41 2014 -0400 Subject: [PATCH] sss_client: Fix "struct sss_cli_mc_ctx" reinitialize-on-errors When we have difficulty setting up an sss_cli_mc_ctx structure, we try to clean things up so that we'll be ready to try again the next time we're called. Part of that is closing the descriptor of the file if we've opened it and using memset() to clear the structure. Now that sss_nss_mc_get_ctx() does its work in two phases, and each one may end up doing the cleanup, each needs to be careful to reset the descriptor field so that the new value provided by memset() (0) isn't mistakenly treated as a file which should be closed by the other. Resolves: https://fedorahosted.org/sssd/ticket/2409 --- src/sss_client/nss_mc_common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sss_client/nss_mc_common.c b/src/sss_client/nss_mc_common.c index cd1ac42da66a2546cb8dec1e8e79088883a870a1..6c9b35de280c637bf957207993e539c889b16c23 100644 --- a/src/sss_client/nss_mc_common.c +++ b/src/sss_client/nss_mc_common.c @@ -164,6 +164,7 @@ done: close(ctx->fd); } memset(ctx, 0, sizeof(struct sss_cli_mc_ctx)); + ctx->fd = -1; } free(file); sss_nss_unlock(); @@ -197,6 +198,7 @@ done: close(ctx->fd); } memset(ctx, 0, sizeof(struct sss_cli_mc_ctx)); + ctx->fd = -1; } return ret; } -- 1.9.3