From c9651182c66b2490b2a7180b7844ec86705593c9 Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Sat, 17 May 2003 04:21:57 +0000 Subject: [PATCH] MFB(r-1.74.2.8) Bug #14369. ftp extension allows circumvention of safe_mode restrictions. HEAD version of this patch uses the simpler open_wrapper approach to applying safe mode restrictions. Also allows writting to/from wrappers this way. --- ext/ftp/php_ftp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index e2f19a4b47e..cdd29e5a59f 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -649,9 +649,9 @@ PHP_FUNCTION(ftp_get) } if (ftp->autoseek && resumepos) { - outstream = php_stream_fopen(local, "rb+", NULL); + outstream = php_stream_open_wrapper(local, "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); if (outstream == NULL) { - outstream = php_stream_fopen(local, "wb", NULL); + outstream = php_stream_open_wrapper(local, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); } if (outstream != NULL) { /* if autoresume is wanted seek to end */ @@ -663,7 +663,7 @@ PHP_FUNCTION(ftp_get) } } } else { - outstream = php_stream_fopen(local, "wb", NULL); + outstream = php_stream_open_wrapper(local, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); } if (outstream == NULL) { @@ -707,9 +707,9 @@ PHP_FUNCTION(ftp_nb_get) } if (ftp->autoseek && resumepos) { - outstream = php_stream_fopen(local, "rb+", NULL); + outstream = php_stream_open_wrapper(local, "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); if (outstream == NULL) { - outstream = php_stream_fopen(local, "wb", NULL); + outstream = php_stream_open_wrapper(local, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); } if (outstream != NULL) { /* if autoresume is wanted seek to end */ @@ -721,7 +721,7 @@ PHP_FUNCTION(ftp_nb_get) } } } else { - outstream = php_stream_fopen(local, "wb", NULL); + outstream = php_stream_open_wrapper(local, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); } if (outstream == NULL) { @@ -902,7 +902,7 @@ PHP_FUNCTION(ftp_put) ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); XTYPE(xtype, mode); - if (!(instream = php_stream_fopen(local, "rb", NULL))) { + if (!(instream = php_stream_open_wrapper(local, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) { RETURN_FALSE; } @@ -955,7 +955,7 @@ PHP_FUNCTION(ftp_nb_put) ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); XTYPE(xtype, mode); - if (!(instream = php_stream_fopen(local, "rb", NULL))) { + if (!(instream = php_stream_open_wrapper(local, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) { RETURN_FALSE; }