]> granicus.if.org Git - php/commitdiff
fix fwrite to no longer apply stripslashes on input string when
authorMarcus Boerger <helly@php.net>
Mon, 26 Aug 2002 23:18:59 +0000 (23:18 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 26 Aug 2002 23:18:59 +0000 (23:18 +0000)
magic_quotes_runtime is set On.

ext/standard/file.c

index d02e86d5ca448a4b0bd623aa82ef0741a2969112..84cc8020e70c3711a975d6b6496b77dab8175951 100644 (file)
@@ -1320,6 +1320,7 @@ PHPAPI PHP_FUNCTION(fwrite)
        int ret, type;
        int num_bytes;
        void *what;
+       char *buffer = NULL;
 
        switch (ZEND_NUM_ARGS()) {
        case 2:
@@ -1347,11 +1348,14 @@ PHPAPI PHP_FUNCTION(fwrite)
        ZEND_VERIFY_RESOURCE(what);
 
        if (!arg3 && PG(magic_quotes_runtime)) {
-               zval_copy_ctor(*arg2);
-               php_stripslashes(Z_STRVAL_PP(arg2), &num_bytes TSRMLS_CC);
+               buffer = estrndup(Z_STRVAL_PP(arg2), Z_STRLEN_PP(arg2));
+               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);
 }