From 8305ac30289532193c11c92df2f2d3fae91f57ac Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 7 Aug 2026 08:15:04 +0000 Subject: [PATCH] path: fix traversal check on Windows On Windows the traversal logic only matched the literal "..\", but Windows accepts "/" as well. Fix SCPathContainsTraversal() on Windows to check both "..\\" and "../". Ticket: #8830. --- src/util-path.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util-path.c b/src/util-path.c index 072133c04b..8226704b0d 100644 --- a/src/util-path.c +++ b/src/util-path.c @@ -268,11 +268,11 @@ const char *SCBasename(const char *path) bool SCPathContainsTraversal(const char *path) { #ifdef OS_WIN32 - const char *pattern = "..\\"; + /* Win32 treats '/' and '\\' as equivalent directory separators */ + return strstr(path, "../") != NULL || strstr(path, "..\\") != NULL; #else - const char *pattern = "../"; + return strstr(path, "../") != NULL; #endif - return strstr(path, pattern) != NULL; } /**