summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-11-15 18:57:14 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-11-15 18:57:14 +0000
commit86cca4e6961d88fd313aa139b188a88a94402b15 (patch)
treeae4284a9d4a75c916c5f71e6fb8894317e64fdf4
parent0aae13f9d23ce513c2b2d2212df9124331b778b5 (diff)
downloadphp-git-86cca4e6961d88fd313aa139b188a88a94402b15.tar.gz
Completed fix for bug #42739 (fixes bug #43276)
-rw-r--r--main/safe_mode.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/main/safe_mode.c b/main/safe_mode.c
index 97c7613dde..e14ba189f9 100644
--- a/main/safe_mode.c
+++ b/main/safe_mode.c
@@ -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);