Blame SOURCES/0007-Fix-file-descriptor-leak-when-executing-CA-helpers.patch

2c4167
From f9c774f737a060b355533c215d7443b9865992a0 Mon Sep 17 00:00:00 2001
2c4167
From: Rob Crittenden <rcritten@redhat.com>
2c4167
Date: Thu, 12 Aug 2021 16:26:09 -0400
2c4167
Subject: [PATCH] Fix file descriptor leak when executing CA helpers
2c4167
2c4167
cm_cadata_start_generic() creates a pipe. One half is passed
2c4167
to fetch(), the function that does all helper calls,
2c4167
via the cm_cadata_state variable ret. The other half is the
2c4167
reader and is used to detect execution errors. There is a pair
2c4167
of write/read on this descriptor which on error would be the
2c4167
errno.
2c4167
2c4167
This second half wasn't being closed after reading to test for
2c4167
errors.
2c4167
2c4167
https://bugzilla.redhat.com/show_bug.cgi?id=1992439
2c4167
2c4167
Signed-off-by: Rob Crittenden <rcritten@redhat.com>
2c4167
---
2c4167
 src/cadata.c | 2 ++
2c4167
 1 file changed, 2 insertions(+)
2c4167
2c4167
diff --git a/src/cadata.c b/src/cadata.c
2c4167
index 3e916c9..d851b9e 100644
2c4167
--- a/src/cadata.c
2c4167
+++ b/src/cadata.c
2c4167
@@ -772,8 +772,10 @@ cm_cadata_start_generic(struct cm_store_ca *ca, const char *op,
2c4167
 		cm_log(1, "Error running enrollment helper \"%s\": %s.\n",
2c4167
 		       ca->cm_ca_external_helper, strerror(u));
2c4167
 		talloc_free(ret);
2c4167
+		close(error_fd[0]);
2c4167
 		return NULL;
2c4167
 	}
2c4167
+	close(error_fd[0]);
2c4167
 	return ret;
2c4167
 }
2c4167
 
2c4167
-- 
2c4167
2.31.1
2c4167