com php-src: remove casts and ensure no out of bounds access: ext/standard/dl.c main/php_ini.c

From: Date: Fri, 21 Jul 2017 20:26:37 +0000
Subject: com php-src: remove casts and ensure no out of bounds access: ext/standard/dl.c main/php_ini.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-98702@lists.php.net to get a copy of this message
Commit: 7ec8b8d49f42e6edf520324b202c5754cd6d9e90 Author: Anatol Belski <ab@php.net> Fri, 21 Jul 2017 22:26:37 +0200 Parents: f8ffc9622ba3f9b9fbbf6d4357868d4e7901fa50 Branches: PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7ec8b8d49f42e6edf520324b202c5754cd6d9e90 Log: remove casts and ensure no out of bounds access Changed paths: M ext/standard/dl.c M main/php_ini.c Diff: diff --git a/ext/standard/dl.c b/ext/standard/dl.c index 1739648..f740792 100644 --- a/ext/standard/dl.c +++ b/ext/standard/dl.c @@ -135,8 +135,7 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now) } libpath = estrdup(filename); } else if (extension_dir && extension_dir[0]) { - int extension_dir_len = (int)strlen(extension_dir); - slash_suffix = IS_SLASH(extension_dir[extension_dir_len-1]); + slash_suffix = IS_SLASH(extension_dir[strlen(extension_dir)-1]); /* Try as filename first */ if (slash_suffix) { spprintf(&libpath, 0, "%s%s", extension_dir, filename); /* SAFE */ diff --git a/main/php_ini.c b/main/php_ini.c index 4e013c8..7b03750 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -353,7 +353,7 @@ static void php_load_php_extension_cb(void *arg) static void php_load_zend_extension_cb(void *arg) { char *filename = *((char **) arg); - const int length = (int)strlen(filename); + const size_t length = strlen(filename); #ifndef PHP_WIN32 (void) length; @@ -365,9 +365,13 @@ static void php_load_zend_extension_cb(void *arg) DL_HANDLE handle; char *libpath; char *extension_dir = INI_STR("extension_dir"); - int extension_dir_len = (int)strlen(extension_dir); - int slash_suffix = IS_SLASH(extension_dir[extension_dir_len-1]); + int slash_suffix = 0; char *err1, *err2; + + if (extension_dir && extension_dir[0]) { + slash_suffix = IS_SLASH(extension_dir[strlen(extension_dir)-1]); + } + /* Try as filename first */ if (slash_suffix) { spprintf(&libpath, 0, "%s%s", extension_dir, filename); /* SAFE */

« previous php.cvs (#98702) next »