cvs: php-src(PHP_5_2) /ext/bz2 bz2.c
| From: | Antony Dovgal | Date: | Wed, 21 Jun 2006 13:12:37 +0000 |
| Subject: | cvs: php-src(PHP_5_2) /ext/bz2 bz2.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-38850@lists.php.net to get a copy of this message | ||
tony2001 Wed Jun 21 13:12:37 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/bz2 bz2.c
Log:
MFH: don't try to read or write from/to a stream if it was open in different mode (leads to
segfault in libbz2)
http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.2&r2=1.14.2.3.2.3&diff_format=u
Index: php-src/ext/bz2/bz2.c
diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.2 php-src/ext/bz2/bz2.c:1.14.2.3.2.3
--- php-src/ext/bz2/bz2.c:1.14.2.3.2.2 Wed Jun 21 12:43:27 2006
+++ php-src/ext/bz2/bz2.c Wed Jun 21 13:12:37 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: bz2.c,v 1.14.2.3.2.2 2006/06/21 12:43:27 tony2001 Exp $ */
+/* $Id: bz2.c,v 1.14.2.3.2.3 2006/06/21 13:12:37 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -384,6 +384,18 @@
php_stream_from_zval(stream, file);
+ if (!memchr(stream->mode, Z_STRVAL_PP(mode)[0], strlen(stream->mode))) {
+ switch (Z_STRVAL_PP(mode)[0]) {
+ case 'r':
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot read from a stream opened in write
only mode");
+ break;
+ case 'w':
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot write to a stream opened in read only
mode");
+ break;
+ }
+ RETURN_FALSE;
+ }
+
if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_FD, (void *) &fd, REPORT_ERRORS)) {
RETURN_FALSE;
}