Skip to content

Commit bd4150e

Browse files
author
Gavin Sherry
committed
Fixed buffer overflow issue.
1 parent 766de15 commit bd4150e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ext/standard/string.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,16 +3289,23 @@ PHPAPI void php_strip_tags(char *rbuf, int len, int state, char *allow, int allo
32893289
break;
32903290

32913291
case '?':
3292-
if (state==1 && *(p-1)=='<' && *(p+1) != 'x'
3293-
&& *(p+2) != 'm' && *(p+3) != 'l') {
32943292

3293+
if (state==1 && *(p-1)=='<') {
32953294
br=0;
32963295
state=2;
32973296
break;
32983297
}
3299-
/* else, it is xml, since state == 1, lets just fall through
3300-
* to '>'
3301-
*/
3298+
3299+
case 'l':
3300+
3301+
/* swm: If we encounter '<?xml' then we shouldn't be in
3302+
* state == 2 (PHP). Switch back to HTML.
3303+
*/
3304+
3305+
if(state == 2 && *(p-1) == 'm' && *(p-2) == 'x') {
3306+
state = 1;
3307+
break;
3308+
}
33023309

33033310
/* fall-through */
33043311
default:

0 commit comments

Comments
 (0)