mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02:00
fix fwrite to no longer apply stripslashes on input string when
magic_quotes_runtime is set On.
This commit is contained in:
parent
f0b492b88d
commit
6063c8c478
1 changed files with 7 additions and 3 deletions
|
@ -1320,6 +1320,7 @@ PHPAPI PHP_FUNCTION(fwrite)
|
||||||
int ret, type;
|
int ret, type;
|
||||||
int num_bytes;
|
int num_bytes;
|
||||||
void *what;
|
void *what;
|
||||||
|
char *buffer = NULL;
|
||||||
|
|
||||||
switch (ZEND_NUM_ARGS()) {
|
switch (ZEND_NUM_ARGS()) {
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -1347,11 +1348,14 @@ PHPAPI PHP_FUNCTION(fwrite)
|
||||||
ZEND_VERIFY_RESOURCE(what);
|
ZEND_VERIFY_RESOURCE(what);
|
||||||
|
|
||||||
if (!arg3 && PG(magic_quotes_runtime)) {
|
if (!arg3 && PG(magic_quotes_runtime)) {
|
||||||
zval_copy_ctor(*arg2);
|
buffer = estrndup(Z_STRVAL_PP(arg2), Z_STRLEN_PP(arg2));
|
||||||
php_stripslashes(Z_STRVAL_PP(arg2), &num_bytes TSRMLS_CC);
|
php_stripslashes(buffer, &num_bytes TSRMLS_CC);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = php_stream_write((php_stream *) what, Z_STRVAL_PP(arg2), num_bytes);
|
ret = php_stream_write((php_stream *) what, buffer ? buffer : Z_STRVAL_PP(arg2), num_bytes);
|
||||||
|
if (buffer) {
|
||||||
|
efree(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_LONG(ret);
|
RETURN_LONG(ret);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue