Skip to content

Commit ceae816

Browse files
committed
Fix #73527: Invalid memory access in php_filter_strip
1 parent b8e7b30 commit ceae816

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ PHP NEWS
77
. Fixed bug #79668 (get_defined_functions(true) may miss functions). (cmb,
88
Nikita)
99

10+
- Filter:
11+
. Fixed bug #73527 (Invalid memory access in php_filter_strip). (cmb)
12+
1013
- PDO SQLite:
1114
. Fixed bug #79664 (PDOStatement::getColumnMeta fails on empty result set).
1215
(cmb)

ext/filter/sanitizing_filters.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static void php_filter_strip(zval *value, zend_long flags)
110110
{
111111
unsigned char *str;
112112
size_t i;
113-
int c;
113+
size_t c;
114114
zend_string *buf;
115115

116116
/* Optimization for if no strip flags are set */
@@ -119,7 +119,7 @@ static void php_filter_strip(zval *value, zend_long flags)
119119
}
120120

121121
str = (unsigned char *)Z_STRVAL_P(value);
122-
buf = zend_string_alloc(Z_STRLEN_P(value) + 1, 0);
122+
buf = zend_string_alloc(Z_STRLEN_P(value), 0);
123123
c = 0;
124124
for (i = 0; i < Z_STRLEN_P(value); i++) {
125125
if ((str[i] >= 127) && (flags & FILTER_FLAG_STRIP_HIGH)) {
@@ -161,7 +161,7 @@ static void filter_map_apply(zval *value, filter_map *map)
161161
zend_string *buf;
162162

163163
str = (unsigned char *)Z_STRVAL_P(value);
164-
buf = zend_string_alloc(Z_STRLEN_P(value) + 1, 0);
164+
buf = zend_string_alloc(Z_STRLEN_P(value), 0);
165165
c = 0;
166166
for (i = 0; i < Z_STRLEN_P(value); i++) {
167167
if ((*map)[str[i]]) {

0 commit comments

Comments
 (0)