com php-src: Replace strncat in filter implementation: ext/standard/user_filters.c main/streams/filter.c

From: Date: Fri, 23 Aug 2019 14:18:50 +0000
Subject: com php-src: Replace strncat in filter implementation: ext/standard/user_filters.c main/streams/filter.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-108012@lists.php.net to get a copy of this message
Commit: 724a4662b8c8b9a9167e7bf2de5dabbd6533056d Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 23 Aug 2019 15:51:57 +0200 Parents: 9173c21a35e42cbe98fac1e28bde300d1e27af61 Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=724a4662b8c8b9a9167e7bf2de5dabbd6533056d Log: Replace strncat in filter implementation In this case we already know exactly where we need to write, no need to use strncat at all. Changed paths: M ext/standard/user_filters.c M main/streams/filter.c Diff: diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index 4fb177a...6cba49b 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -292,8 +292,9 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, memcpy(wildcard, filtername, len + 1); /* copy \0 */ period = wildcard + (period - filtername); while (period) { - *period = '\0'; - strncat(wildcard, ".*", 2); + ZEND_ASSERT(period[0] == '.'); + period[1] = '*'; + period[2] = '\0'; if (NULL != (fdat = zend_hash_str_find_ptr(BG(user_filter_map), wildcard, strlen(wildcard)))) { period = NULL; } else { diff --git a/main/streams/filter.c b/main/streams/filter.c index afc1f3b..7fdbd0c 100644 --- a/main/streams/filter.c +++ b/main/streams/filter.c @@ -239,8 +239,9 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval memcpy(wildname, filtername, n+1); period = wildname + (period - filtername); while (period && !filter) { - *period = '\0'; - strncat(wildname, ".*", 2); + ZEND_ASSERT(period[0] == '.'); + period[1] = '*'; + period[2] = '\0'; if (NULL != (factory = zend_hash_str_find_ptr(filter_hash, wildname, strlen(wildname)))) { filter = factory->create_filter(filtername, filterparams, persistent); }

« previous php.cvs (#108012) next »