[PATCH v2 04/10] sandbox/seunshare: make -W/-P .. check exact

Stephen Smalley <[email protected]>
Newsgroups org.kernel.vger.selinux
Message-ID <[email protected]>
Given the strchr(..., "/") checks to prevent any pathname separator
characters from being embedded in the -W/-P names, we only need to
further check for ".." exactly via strcmp() rather than a substring
check via strstr().

Signed-off-by: Stephen Smalley <[email protected]>
---
 sandbox/seunshare.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sandbox/seunshare.c b/sandbox/seunshare.c
index 1e7822e5..37a24c57 100644
--- a/sandbox/seunshare.c
+++ b/sandbox/seunshare.c
@@ -881,10 +881,10 @@ int main(int argc, char **argv)
 		}
 	}
 
-	if ((wayland_display &&
-	     (strchr(wayland_display, '/') || strstr(wayland_display, ".."))) ||
-	    (pipewire_socket &&
-	     (strchr(pipewire_socket, '/') || strstr(pipewire_socket, "..")))) {
+	if ((wayland_display && (strchr(wayland_display, '/') ||
+				 !strcmp(wayland_display, ".."))) ||
+	    (pipewire_socket && (strchr(pipewire_socket, '/') ||
+				 !strcmp(pipewire_socket, "..")))) {
 		fprintf(stderr,
 			_("Error: -W/-P must be a socket name, not a path\n"));
 		return -1;
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.