]> granicus.if.org Git - php/commitdiff
Completed fix for bug #42739 (fixes bug #43276)
authorIlia Alshanetsky <iliaa@php.net>
Thu, 15 Nov 2007 18:57:14 +0000 (18:57 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 15 Nov 2007 18:57:14 +0000 (18:57 +0000)
main/safe_mode.c

index 97c7613ddef8e5e3fe847ffc1e3dfccdcf7304ce..e14ba189f99156368915451bfa901c886465644c 100644 (file)
@@ -122,10 +122,17 @@ PHPAPI int php_checkuid_ex(const char *filename, const char *fopen_mode, int mod
 
                /* Trim off filename */
                if ((s = strrchr(path, DEFAULT_SLASH))) {
-                       if (s == path)
-                               path[1] = '\0';
-                       else
+                       if (*(s + 1) == '\0' && s != path) { /* make sure that the / is not the last character */
                                *s = '\0';
+                               s = strrchr(path, DEFAULT_SLASH);
+                       }
+                       if (s) {
+                               if (s == path) {
+                                       path[1] = '\0';
+                               } else {
+                                       *s = '\0';
+                               }
+                       }
                }
        } else { /* CHECKUID_ALLOW_ONLY_DIR */
                s = strrchr(filename, DEFAULT_SLASH);