com php-src: fix up porting mistakes: Zend/zend_virtual_cwd .c ext/phar/phar_object.c
| From: | Anatol Belski | Date: | Thu, 27 Jul 2017 21:38:04 +0000 |
| Subject: | com php-src: fix up porting mistakes: Zend/zend_virtual_cwd .c ext/phar/phar_object.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98838@lists.php.net to get a copy of this message | ||
Commit: 827284ec36de4257509e7e68a7a74d27145e989f
Author: Anatol Belski <ab@php.net> Thu, 27 Jul 2017 23:38:04 +0200
Parents: 49d9b3013fb2ee18b59694aa36036104a4bdd6f2
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=827284ec36de4257509e7e68a7a74d27145e989f
Log:
fix up porting mistakes
Changed paths:
M Zend/zend_virtual_cwd.c
M ext/phar/phar_object.c
Diff:
diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c
index e0d890a..5ed84c3 100644
--- a/Zend/zend_virtual_cwd.c
+++ b/Zend/zend_virtual_cwd.c
@@ -737,6 +737,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
while (i > start && !IS_SLASH(path[i-1])) {
i--;
}
+ assert(i < MAXPATHLEN);
if (i == len ||
(i + 1 == len && path[i] == '.')) {
@@ -744,7 +745,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
len = i - 1;
is_dir = 1;
continue;
- } else if (i == len - 2 && path[i] == '.' && path[i+1] ==
'.') {
+ } else if (i + 2 == len && path[i] == '.' && path[i+1] ==
'.') {
/* remove '..' and previous directory */
is_dir = 1;
if (link_is_dir) {
@@ -754,11 +755,13 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll,
tim
return start ? start : len;
}
j = tsrm_realpath_r(path, start, i-1, ll, t, use_realpath, 1, NULL);
- if (j > start) {
+ if (j > start && j != (size_t)-1) {
j--;
+ assert(i < MAXPATHLEN);
while (j > start && !IS_SLASH(path[j])) {
j--;
}
+ assert(i < MAXPATHLEN);
if (!start) {
/* leading '..' must not be removed in case of relative path */
if (j == 0 && path[0] == '.' && path[1] == '.' &&
@@ -1119,7 +1122,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll,
tim
} else {
/* some leading directories may be unaccessable */
j = tsrm_realpath_r(path, start, i-1, ll, t, save ? CWD_FILEPATH : use_realpath, 1, NULL);
- if (j > start) {
+ if (j > start && j != (size_t)-1) {
path[j++] = DEFAULT_SLASH;
}
}
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index 7b9f807..af4ccba 100644
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -4212,7 +4212,7 @@ static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char
*
if ('\\' == filename[cnt]) {
filename[cnt] = '/';
}
- } while (cnt++ < filename_len);
+ } while (cnt++ <= filename_len);
}
#endif