From 2f26fcdc2a68e316e9a09e8d716990fea6d92138 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 30 Jul 2024 14:22:08 +0300 Subject: [PATCH] public: disallow backslashes in COM_PathSlashFix --- public/crtlib.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/public/crtlib.c b/public/crtlib.c index ca111d34..d9df3d68 100644 --- a/public/crtlib.c +++ b/public/crtlib.c @@ -686,15 +686,19 @@ void COM_FixSlashes( char *pname ) /* ============ COM_PathSlashFix + +ensure directory path always ends on forward slash ============ */ void COM_PathSlashFix( char *path ) { - size_t len; + size_t len = Q_strlen( path ); - len = Q_strlen( path ); - - if( path[len - 1] != '\\' && path[len - 1] != '/' ) + if( path[len - 1] == '\\' ) + { + path[len - 1] = '/'; + } + else if( path[len - 1] != '/' ) { path[len] = '/'; path[len + 1] = '\0';