From 383d370cee1a049f07796a603b4cbbce2800cba6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Apr 07 2020 12:59:45 +0000 Subject: Fix handling of selinux context when NULL Fixes #256 Signed-off-by: Simo Sorce --- diff --git a/src/gp_socket.c b/src/gp_socket.c index 7a19ee5..9070928 100644 --- a/src/gp_socket.c +++ b/src/gp_socket.c @@ -122,7 +122,9 @@ void gp_conn_free(struct gp_conn *conn) close(conn->us.sd); } free(conn->program); - SELINUX_context_free(conn->selinux_ctx); + if (conn->selinux_ctx) { + SELINUX_context_free(conn->selinux_ctx); + } free(conn); } @@ -635,7 +637,8 @@ void accept_sock_conn(verto_ctx *vctx, verto_ev *ev) conn->creds.ucred.uid, conn->creds.ucred.gid); } - if (conn->creds.type & CRED_TYPE_SELINUX) { + if ((conn->creds.type & CRED_TYPE_SELINUX) && + (conn->selinux_ctx != NULL)) { GPDEBUG(" (context = %s)", SELINUX_context_str(conn->selinux_ctx)); }