[PATCH] libselinux: Fix NULL pointer use in selinux_restorecon_set_sehandle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



error occur when selinux_restorecon_default_handle return NULL in
restorecon_init.

fixes: https://github.com/SELinuxProject/selinux/issues/249

Signed-off-by: Ji Qin <jiqin.ji@xxxxxxxxxx>
---
 libselinux/src/selinux_restorecon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
index 91dfeb66..c2d05a66 100644
--- a/libselinux/src/selinux_restorecon.c
+++ b/libselinux/src/selinux_restorecon.c
@@ -1153,6 +1153,8 @@ void selinux_restorecon_set_sehandle(struct selabel_handle *hndl)
 	size_t num_specfiles, fc_digest_len;
 
 	fc_sehandle = (struct selabel_handle *) hndl;
+	if (!fc_sehandle)
+		return;
 
 	/* Check if digest requested in selabel_open(3), if so use it. */
 	if (selabel_digest(fc_sehandle, &fc_digest, &fc_digest_len,
-- 
2.23.0




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux