]> Git repositories of Nishi - tewi.git/commitdiff
fix
authorNishi <nishi@nishi.boats>
Thu, 19 Sep 2024 09:28:44 +0000 (09:28 +0000)
committerNishi <nishi@nishi.boats>
Thu, 19 Sep 2024 09:28:44 +0000 (09:28 +0000)
git-svn-id: file:///raid/svn-personal/tewi/trunk@71 8739d7e6-ffea-ec47-b151-bdff447c6205

Server/server.c

index 1c78386a8ede39e32297ef05a35040ddacc5976d..678ff375394f661a6fac5378e1dd944b29164a44 100644 (file)
@@ -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) {