|
|
8d87dc |
Adapted for 5.4, binary patch removed, from:
|
|
|
8d87dc |
|
|
|
8d87dc |
|
|
|
8d87dc |
From f3feddb5b45b5abd93abb1a95044b7e099d51c84 Mon Sep 17 00:00:00 2001
|
|
|
8d87dc |
From: Stanislav Malyshev <stas@php.net>
|
|
|
8d87dc |
Date: Mon, 18 Jul 2016 22:20:45 -0700
|
|
|
8d87dc |
Subject: [PATCH] Partial fix for bug #72613 - do not treat negative returns
|
|
|
8d87dc |
from bz2 as size_t
|
|
|
8d87dc |
|
|
|
8d87dc |
---
|
|
|
8d87dc |
ext/bz2/bz2.c | 80 +++++++++++++++++++++++---------------------
|
|
|
8d87dc |
ext/bz2/tests/72613.bz2 | Bin 0 -> 351 bytes
|
|
|
8d87dc |
ext/bz2/tests/bug72613.phpt | 23 +++++++++++++
|
|
|
8d87dc |
3 files changed, 65 insertions(+), 38 deletions(-)
|
|
|
8d87dc |
create mode 100644 ext/bz2/tests/72613.bz2
|
|
|
8d87dc |
create mode 100644 ext/bz2/tests/bug72613.phpt
|
|
|
8d87dc |
|
|
|
8d87dc |
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c
|
|
|
8d87dc |
index de3250e..7cfcaa8 100644
|
|
|
8d87dc |
--- a/ext/bz2/bz2.c
|
|
|
8d87dc |
+++ b/ext/bz2/bz2.c
|
|
|
8d87dc |
@@ -137,16 +137,20 @@ struct php_bz2_stream_data_t {
|
|
|
8d87dc |
static size_t php_bz2iop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
|
|
|
8d87dc |
{
|
|
|
8d87dc |
struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *) stream->abstract;
|
|
|
8d87dc |
- size_t ret;
|
|
|
8d87dc |
-
|
|
|
8d87dc |
- ret = BZ2_bzread(self->bz_file, buf, count);
|
|
|
8d87dc |
+ int bz2_ret;
|
|
|
8d87dc |
+
|
|
|
8d87dc |
+ bz2_ret = BZ2_bzread(self->bz_file, buf, count);
|
|
|
8d87dc |
|
|
|
8d87dc |
- if (ret == 0) {
|
|
|
8d87dc |
+ if (bz2_ret < 0) {
|
|
|
8d87dc |
+ stream->eof = 1;
|
|
|
8d87dc |
+ return -1;
|
|
|
8d87dc |
+ }
|
|
|
8d87dc |
+ if (bz2_ret == 0) {
|
|
|
8d87dc |
stream->eof = 1;
|
|
|
8d87dc |
}
|
|
|
8d87dc |
|
|
|
8d87dc |
- return ret;
|
|
|
8d87dc |
+ return (size_t)bz2_ret;
|
|
|
8d87dc |
}
|
|
|
8d87dc |
|
|
|
8d87dc |
static size_t php_bz2iop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
|
|
|
8d87dc |
{
|