aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2023-08-20 12:46:33 +0800
committerPo Lu2023-08-20 12:48:03 +0800
commitfd1479a0af1ba896ae194c9fc91ec7dd49416d9b (patch)
treef839c95a83fac467294838babe8de8a9fd6170f3 /src
parent15e498047f8d37526e0c361e369e5f06c4712db3 (diff)
downloademacs-fd1479a0af1ba896ae194c9fc91ec7dd49416d9b.tar.gz
emacs-fd1479a0af1ba896ae194c9fc91ec7dd49416d9b.zip
Fix libselinux object leaks
* src/fileio.c (Fcopy_file, Fset_file_selinux_context): Call freecon prior to signaling file errors.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/fileio.c b/src/fileio.c
index fc9b04678f5..51e3e8849d1 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2496,6 +2496,8 @@ permissions. */)
2496 { 2496 {
2497 /* Set the modified context back to the file. */ 2497 /* Set the modified context back to the file. */
2498 bool fail = fsetfilecon (ofd, con) != 0; 2498 bool fail = fsetfilecon (ofd, con) != 0;
2499 freecon (con);
2500
2499 /* See https://debbugs.gnu.org/11245 for ENOTSUP. */ 2501 /* See https://debbugs.gnu.org/11245 for ENOTSUP. */
2500 if (fail 2502 if (fail
2501#if defined HAVE_ANDROID && !defined ANDROID_STUBIFY 2503#if defined HAVE_ANDROID && !defined ANDROID_STUBIFY
@@ -2506,8 +2508,6 @@ permissions. */)
2506#endif /* defined HAVE_ANDROID && !defined ANDROID_STUBIFY */ 2508#endif /* defined HAVE_ANDROID && !defined ANDROID_STUBIFY */
2507 && errno != ENOTSUP) 2509 && errno != ENOTSUP)
2508 report_file_error ("Doing fsetfilecon", newname); 2510 report_file_error ("Doing fsetfilecon", newname);
2509
2510 freecon (con);
2511 } 2511 }
2512#endif 2512#endif
2513 2513
@@ -3510,12 +3510,12 @@ or if Emacs was not compiled with SELinux support. */)
3510 fail = (lsetfilecon (SSDATA (encoded_absname), 3510 fail = (lsetfilecon (SSDATA (encoded_absname),
3511 context_str (parsed_con)) 3511 context_str (parsed_con))
3512 != 0); 3512 != 0);
3513 context_free (parsed_con);
3514 freecon (con);
3515
3513 /* See https://debbugs.gnu.org/11245 for ENOTSUP. */ 3516 /* See https://debbugs.gnu.org/11245 for ENOTSUP. */
3514 if (fail && errno != ENOTSUP) 3517 if (fail && errno != ENOTSUP)
3515 report_file_error ("Doing lsetfilecon", absname); 3518 report_file_error ("Doing lsetfilecon", absname);
3516
3517 context_free (parsed_con);
3518 freecon (con);
3519 return fail ? Qnil : Qt; 3519 return fail ? Qnil : Qt;
3520 } 3520 }
3521 else 3521 else