From d26da0e5453ab68bba6f48c6bd967c9f9d6f3e71 Mon Sep 17 00:00:00 2001 From: Nishi Date: Thu, 19 Sep 2024 09:28:44 +0000 Subject: [PATCH] fix git-svn-id: file:///raid/svn-personal/tewi/trunk@71 8739d7e6-ffea-ec47-b151-bdff447c6205 --- Server/server.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Server/server.c b/Server/server.c index 1c78386..678ff37 100644 --- a/Server/server.c +++ b/Server/server.c @@ -485,9 +485,16 @@ void tw_server_pass(int sock, bool ssl, int port, SOCKADDR addr) { cm_log("Server", "Filesystem path is %s", path); bool rej = false; #ifdef __MINGW32__ + char* rpath = cm_strdup(path); + for(i = strlen(rpath) - 1; i >= 0; i++) { + if(rpath[i] != ':'){ + break; + } + rpath[i] = 0; + } for(i = 0; i < sizeof(reserved_names) / sizeof(reserved_names[0]); i++) { char* n = cm_strcat("/", reserved_names[i]); - if(cm_nocase_endswith(path, n)) { + if(cm_nocase_endswith(rpath, n)) { tw_http_error(s, sock, 403, name, port); free(n); rej = true; @@ -495,16 +502,8 @@ void tw_server_pass(int sock, bool ssl, int port, SOCKADDR addr) { break; } free(n); - char* y = cm_strcat3("/", reserved_names[i], ":"); - if(cm_nocase_endswith(path, y)) { - tw_http_error(s, sock, 403, name, port); - free(y); - rej = true; - cm_log("Server", "XP Patch ; rejecting access to device"); - break; - } - free(y); } + free(rpath); #endif struct stat st; if(!rej && stat(path, &st) == 0) { -- 2.43.0