iliaa Wed Mar 14 03:50:18 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/zip zip_stream.c
/php-src/ext/bz2 bz2.c
Log:
Added missing open_basedir & safe_mode checks to zip:// and bzip://
wrappers.
Issues idendtified by MOPB-20 and MOPB-21
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/zip_stream.c?r1=1.1.2.3&r2=1.1.2.4&diff_format=u
Index: php-src/ext/zip/zip_stream.c
diff -u php-src/ext/zip/zip_stream.c:1.1.2.3
php-src/ext/zip/zip_stream.c:1.1.2.4
--- php-src/ext/zip/zip_stream.c:1.1.2.3 Sat Dec 23 23:28:39 2006
+++ php-src/ext/zip/zip_stream.c Wed Mar 14 03:50:18 2007
@@ -1,4 +1,4 @@
-/* $Id: zip_stream.c,v 1.1.2.3 2006/12/23 23:28:39 iliaa Exp $ */
+/* $Id: zip_stream.c,v 1.1.2.4 2007/03/14 03:50:18 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
@@ -112,6 +112,10 @@
}
if (filename) {
+ if ((PG(safe_mode) && (!php_checkuid(filename, NULL,
CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC)) {
+ return NULL;
+ }
+
/* duplicate to make the stream za independent (esp. for
MSHUTDOWN) */
stream_za = zip_open(filename, ZIP_CREATE, &err);
if (!stream_za) {
@@ -189,6 +193,11 @@
php_basename(path, path_len - fragment_len, NULL, 0, &file_basename,
&file_basename_len TSRMLS_CC);
fragment++;
+ if ((PG(safe_mode) && (!php_checkuid(file_dirname, NULL,
CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(file_dirname
TSRMLS_CC)) {
+ efree(file_basename);
+ return NULL;
+ }
+
za = zip_open(file_dirname, ZIP_CREATE, &err);
if (za) {
zf = zip_fopen(za, fragment, 0);
http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.11&r2=1.14.2.3.2.12&diff_format=u
Index: php-src/ext/bz2/bz2.c
diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.11 php-src/ext/bz2/bz2.c:1.14.2.3.2.12
--- php-src/ext/bz2/bz2.c:1.14.2.3.2.11 Tue Mar 6 02:10:25 2007
+++ php-src/ext/bz2/bz2.c Wed Mar 14 03:50:18 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: bz2.c,v 1.14.2.3.2.11 2007/03/06 02:10:25 stas Exp $ */
+/* $Id: bz2.c,v 1.14.2.3.2.12 2007/03/14 03:50:18 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -225,6 +225,10 @@
#else
path_copy = path;
#endif
+
+ if ((PG(safe_mode) && (!php_checkuid(path_copy, NULL,
CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(path_copy TSRMLS_CC)) {
+ return NULL;
+ }
/* try and open it directly first */
bz_file = BZ2_bzopen(path_copy, mode);
@@ -236,7 +240,7 @@
if (bz_file == NULL) {
/* that didn't work, so try and get something from the
network/wrapper */
- stream = php_stream_open_wrapper(path, mode, options |
STREAM_WILL_CAST, opened_path);
+ stream = php_stream_open_wrapper(path, mode, options |
STREAM_WILL_CAST | ENFORCE_SAFE_MODE, opened_path);
if (stream) {
int fd;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php