summaryrefslogtreecommitdiff
path: root/ext/bz2
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:37:27 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:37:27 -0400
commit2d4e5b09576bb4f0ba716cc82cdf29ea04d9184b (patch)
tree41ccc042009cba53e4ce43e727fcba4c1cfbf7f3 /ext/bz2
parentd29a4fd2dd3b5d4cf6e80b602544d7b71d794e76 (diff)
downloadphp-2d4e5b09576bb4f0ba716cc82cdf29ea04d9184b.tar.gz
Imported Upstream version 5.2.2upstream/5.2.2
Diffstat (limited to 'ext/bz2')
-rw-r--r--ext/bz2/bz2.c16
-rw-r--r--ext/bz2/bz2_filter.c9
-rw-r--r--ext/bz2/php_bz2.h4
3 files changed, 19 insertions, 10 deletions
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c
index b598bdd96..1b1d38d70 100644
--- a/ext/bz2/bz2.c
+++ b/ext/bz2/bz2.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: bz2.c,v 1.14.2.3.2.8 2006/08/17 20:46:51 tony2001 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 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
#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 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
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;
@@ -330,7 +334,7 @@ static PHP_FUNCTION(bzread)
php_stream_from_zval(stream, &bz);
- if (len < 0) {
+ if ((len + 1) < 1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "length may not be negative");
RETURN_FALSE;
}
@@ -562,13 +566,13 @@ static PHP_FUNCTION(bzdecompress)
/* compression is better then 2:1, need to allocate more memory */
bzs.avail_out = source_len;
size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
- dest = erealloc(dest, size + bzs.avail_out + 1);
+ dest = safe_erealloc(dest, 1, bzs.avail_out+1, size );
bzs.next_out = dest + size;
}
if (error == BZ_STREAM_END || error == BZ_OK) {
size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
- dest = erealloc(dest, size + 1);
+ dest = safe_erealloc(dest, 1, size, 1);
dest[size] = '\0';
RETVAL_STRINGL(dest, size, 0);
} else { /* real error */
diff --git a/ext/bz2/bz2_filter.c b/ext/bz2/bz2_filter.c
index 0c74d4732..e11fa3753 100644
--- a/ext/bz2/bz2_filter.c
+++ b/ext/bz2/bz2_filter.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: bz2_filter.c,v 1.3.2.2.2.2 2006/06/23 07:30:26 mike Exp $ */
+/* $Id: bz2_filter.c,v 1.3.2.2.2.4 2007/01/25 12:22:21 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -101,6 +101,11 @@ static php_stream_filter_status_t php_bz2_decompress_filter(
consumed += desired;
bin += desired;
+ if (!desired) {
+ flags |= PSFS_FLAG_FLUSH_CLOSE;
+ break;
+ }
+
if (data->strm.avail_out < data->outbuf_len) {
php_stream_bucket *out_bucket;
size_t bucketlen = data->outbuf_len - data->strm.avail_out;
diff --git a/ext/bz2/php_bz2.h b/ext/bz2/php_bz2.h
index 1c0231d7d..8abf33414 100644
--- a/ext/bz2/php_bz2.h
+++ b/ext/bz2/php_bz2.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_bz2.h,v 1.7.2.1.2.2 2006/08/14 20:08:17 nlopess Exp $ */
+/* $Id: php_bz2.h,v 1.7.2.1.2.3 2007/01/01 09:35:48 sebastian Exp $ */
#ifndef PHP_BZ2_H
#define PHP_BZ2_H