1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 10:43:30 +02:00

Merge branch 'PHP-7.1' into PHP-7.2

* PHP-7.1:
  Fix stack underflow in phar
This commit is contained in:
Anatol Belski
2018-08-30 19:34:01 +02:00
+7 -10
View File
@@ -1832,27 +1832,24 @@ static int phar_analyze_path(const char *fname, const char *ext, int ext_len, in
/* check for ".phar" in extension */
static int phar_check_str(const char *fname, const char *ext_str, int ext_len, int executable, int for_create) /* {{{ */
{
char test[51];
const char *pos;
if (ext_len < 0 || ext_len >= 50) {
return FAILURE;
}
if (executable == 1) {
/* copy "." as well */
memcpy(test, ext_str - 1, ext_len + 1);
test[ext_len + 1] = '\0';
/* executable phars must contain ".phar" as a valid extension (phar://.pharmy/oops is invalid) */
/* (phar://hi/there/.phar/oops is also invalid) */
pos = strstr(test, ".phar");
pos = strstr(ext_str, ".phar");
if (pos && (*(pos - 1) != '/')
&& (pos += 5) && (*pos == '\0' || *pos == '/' || *pos == '.')) {
return phar_analyze_path(fname, ext_str, ext_len, for_create);
} else {
if (!pos
|| pos != ext_str && (*(pos - 1) == '/')
|| (ext_len - (pos - ext_str)) < 5
|| !(pos += 5)
|| !(*pos == '\0' || *pos == '/' || *pos == '.')) {
return FAILURE;
}
return phar_analyze_path(fname, ext_str, ext_len, for_create);
}
/* data phars need only contain a single non-"." to be valid */