From 3d890f09a86dcf2849ad66552462ec383250cd24 Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Wed, 23 Apr 2008 18:22:09 +0000 Subject: [PATCH] fix extension detection for executable=2 --- ext/phar/phar.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 481930b976..4bb1d7e213 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1509,10 +1509,16 @@ static int phar_check_str(const char *fname, const char *ext_str, int ext_len, i } } /* data phars need only contain a single non-"." to be valid */ - pos = strstr(ext_str, ".phar"); - if (!(pos && (*(pos - 1) != '/') - && (pos += 5) && (*pos == '\0' || *pos == '/' || *pos == '.')) && *(ext_str + 1) != '.' && *(ext_str + 1) != '/' && *(ext_str + 1) != '\0') { - return phar_analyze_path(fname, ext_str, ext_len, for_create TSRMLS_CC); + if (!executable) { + pos = strstr(ext_str, ".phar"); + if (!(pos && (*(pos - 1) != '/') + && (pos += 5) && (*pos == '\0' || *pos == '/' || *pos == '.')) && *(ext_str + 1) != '.' && *(ext_str + 1) != '/' && *(ext_str + 1) != '\0') { + return phar_analyze_path(fname, ext_str, ext_len, for_create TSRMLS_CC); + } + } else { + if (*(ext_str + 1) != '.' && *(ext_str + 1) != '/' && *(ext_str + 1) != '\0') { + return phar_analyze_path(fname, ext_str, ext_len, for_create TSRMLS_CC); + } } return FAILURE; } @@ -1599,7 +1605,7 @@ next_extension: if (!pos) { return FAILURE; } - if (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) { + while (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) { pos = strchr(pos + 1, '.'); if (!pos) { return FAILURE; -- 2.50.1