Skip to content

Commit 6da0c2f

Browse files
author
Sjoerd Langkemper
committed
Use zend_long consistently for filter count
We get a zend_long from the stream context, so it makes sense to consistently use it for all counts of filters.
1 parent af279cb commit 6da0c2f

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

ext/standard/php_fopen_wrapper.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,29 +144,29 @@ static const php_stream_ops php_stream_input_ops = {
144144
NULL /* set_option */
145145
};
146146

147-
static const int max_filter_count_default = 16;
147+
static const zend_long max_filter_count_default = 16;
148148

149-
static int php_get_max_filter_count(php_stream_context *context) {
149+
static zend_long php_get_max_filter_count(php_stream_context *context) {
150150
if (context != NULL) {
151151
zval *option_val = php_stream_context_get_option(context, "filter", "max_filter_count");
152152
if (option_val) {
153153
zend_long custom_limit = zval_get_long(option_val);
154154
if (custom_limit >= 0) {
155-
return (int)custom_limit;
155+
return custom_limit;
156156
}
157157
}
158158
}
159159
return -1;
160160
}
161161

162162
static bool php_stream_has_too_many_filters(php_stream *stream, php_stream_context *context) {
163-
int max_filter_count = php_get_max_filter_count(context);
163+
zend_long max_filter_count = php_get_max_filter_count(context);
164164
if (max_filter_count == -1) {
165165
// If not explicitly configured we don't throw an error yet.
166166
return false;
167167
}
168168

169-
int count = MAX(php_stream_filter_count(&stream->readfilters), php_stream_filter_count(&stream->writefilters));
169+
zend_long count = MAX(php_stream_filter_count(&stream->readfilters), php_stream_filter_count(&stream->writefilters));
170170
return count > max_filter_count;
171171
}
172172

@@ -177,7 +177,7 @@ static void php_stream_apply_filter_list(php_stream *stream, char *filterlist, i
177177

178178
p = php_strtok_r(filterlist, "|", &token);
179179
while (p) {
180-
int count = read_chain ? php_stream_filter_count(&stream->readfilters) : write_chain ? php_stream_filter_count(&stream->writefilters) : 0;
180+
zend_long count = read_chain ? php_stream_filter_count(&stream->readfilters) : write_chain ? php_stream_filter_count(&stream->writefilters) : 0;
181181
if (warn_filter_count && count == max_filter_count_default) {
182182
zend_error(E_DEPRECATED, "Using more than %d filters in a php://filter URL is deprecated, "
183183
"set this limit using the stream context option max_filter_count, or use stream_filter_append", max_filter_count_default);

main/streams/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream
447447
}
448448
}
449449

450-
PHPAPI int php_stream_filter_count(php_stream_filter_chain *chain) {
450+
PHPAPI zend_long php_stream_filter_count(php_stream_filter_chain *chain) {
451451
if (chain->head == NULL) {
452452
return 0;
453453
}

main/streams/php_stream_filter_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ PHPAPI void _php_stream_filter_prepend(php_stream_filter_chain *chain, php_strea
138138
PHPAPI void php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter);
139139
PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream_filter *filter);
140140
PHPAPI zend_result php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter);
141-
PHPAPI int php_stream_filter_count(php_stream_filter_chain *chain);
141+
PHPAPI zend_long php_stream_filter_count(php_stream_filter_chain *chain);
142142
PHPAPI zend_result _php_stream_filter_flush(php_stream_filter *filter, bool finish);
143143
PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, bool call_dtor);
144144
PHPAPI void php_stream_filter_free(php_stream_filter *filter);

0 commit comments

Comments
 (0)