Skip to content

Commit 724a466

Browse files
committed
Replace strncat in filter implementation
In this case we already know exactly where we need to write, no need to use strncat at all.
1 parent 9173c21 commit 724a466

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

ext/standard/user_filters.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,9 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
292292
memcpy(wildcard, filtername, len + 1); /* copy \0 */
293293
period = wildcard + (period - filtername);
294294
while (period) {
295-
*period = '\0';
296-
strncat(wildcard, ".*", 2);
295+
ZEND_ASSERT(period[0] == '.');
296+
period[1] = '*';
297+
period[2] = '\0';
297298
if (NULL != (fdat = zend_hash_str_find_ptr(BG(user_filter_map), wildcard, strlen(wildcard)))) {
298299
period = NULL;
299300
} else {

main/streams/filter.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,9 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval
239239
memcpy(wildname, filtername, n+1);
240240
period = wildname + (period - filtername);
241241
while (period && !filter) {
242-
*period = '\0';
243-
strncat(wildname, ".*", 2);
242+
ZEND_ASSERT(period[0] == '.');
243+
period[1] = '*';
244+
period[2] = '\0';
244245
if (NULL != (factory = zend_hash_str_find_ptr(filter_hash, wildname, strlen(wildname)))) {
245246
filter = factory->create_filter(filtername, filterparams, persistent);
246247
}

0 commit comments

Comments
 (0)