From 80bb649ad1ce83dc55481a279a86ccc8b7de5985 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 18 Jun 2018 14:08:50 +0000 Subject: [PATCH] phar module, unsignedness check changes. while at it, correcting seemingly subtle bug when checking extension validity. --- ext/phar/phar.c | 6 +++--- ext/phar/phar_object.c | 7 ------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/ext/phar/phar.c b/ext/phar/phar.c index de3475b63cee..5b4f79846cfb 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1853,14 +1853,14 @@ static int phar_check_str(const char *fname, const char *ext_str, size_t ext_len char test[51]; const char *pos; - if (ext_len < 0 || ext_len >= 50) { + if (ext_len >= 50) { return FAILURE; } if (executable == 1) { /* copy "." as well */ - memcpy(test, ext_str - 1, ext_len + 1); - test[ext_len + 1] = '\0'; + strlcpy(test, ext_str, ext_len + 1); + /* 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"); diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 32a7a31e7fde..5f866c6b2ae3 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -389,13 +389,6 @@ static void phar_postprocess_ru_web(char *fname, size_t fname_len, char **entry, u[0] = '\0'; u_len = strlen(u + 1); e_len -= u_len + 1; - - if (e_len < 0) { - if (saveu) { - saveu[0] = '/'; - } - return; - } } while (1); } /* }}} */