Blame SOURCES/0007-libsemanage-Fix-USE_AFTER_FREE-CWE-672-in-semanage_d.patch

634418
From 30da7a4907893bd43fe9da40728a3bcabdf3d7a4 Mon Sep 17 00:00:00 2001
634418
From: Petr Lautrbach <plautrba@redhat.com>
634418
Date: Wed, 28 Jul 2021 11:21:35 +0200
634418
Subject: [PATCH] libsemanage: Fix USE_AFTER_FREE (CWE-672) in
634418
 semanage_direct_write_langext()
634418
634418
>From fclose(3):
634418
Upon successful completion, 0 is returned.  Otherwise, EOF is returned
634418
and errno is set to indicate the error. In either case, any further
634418
access (including another call to fclose()) to the stream results in
634418
undefined behavior.
634418
634418
Fixes:
634418
    Error: USE_AFTER_FREE (CWE-672): [#def1]
634418
    libsemanage-3.2/src/direct_api.c:1023: freed_arg: "fclose" frees "fp".
634418
    libsemanage-3.2/src/direct_api.c:1034: use_closed_file: Calling "fclose" uses file handle "fp" after closing it.
634418
    # 1032|
634418
    # 1033|   cleanup:
634418
    # 1034|-> 	if (fp != NULL) fclose(fp);
634418
    # 1035|
634418
    # 1036|   	return ret;
634418
634418
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
634418
---
634418
 libsemanage/src/direct_api.c | 1 +
634418
 1 file changed, 1 insertion(+)
634418
634418
diff --git a/libsemanage/src/direct_api.c b/libsemanage/src/direct_api.c
634418
index c32939c0..7638653a 100644
634418
--- a/libsemanage/src/direct_api.c
634418
+++ b/libsemanage/src/direct_api.c
634418
@@ -1022,6 +1022,7 @@ static int semanage_direct_write_langext(semanage_handle_t *sh,
634418
 
634418
 	if (fclose(fp) != 0) {
634418
 		ERR(sh, "Unable to close %s module ext file.", modinfo->name);
634418
+		fp = NULL;
634418
 		ret = -1;
634418
 		goto cleanup;
634418
 	}
634418
-- 
634418
2.30.2
634418