File tree Expand file tree Collapse file tree 3 files changed +36
-5
lines changed Expand file tree Collapse file tree 3 files changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,12 @@ PHP NEWS
23
23
. Fixed bug #71003 (Expose MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT to PDO
24
24
interface). (Thomas Orozco)
25
25
26
- . Streams:
26
+ - Streams:
27
27
. Fixed bug #74216 (Correctly fail on invalid IP address ports). (Sara)
28
28
29
+ - Zlib:
30
+ . Fixed bug #74240 (deflate_add can allocate too much memory). (Matt Bonneau)
31
+
29
32
16 Mar 2017 PHP 7.0.17
30
33
31
34
- Core:
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #74240 (deflate_add can allocate too much memory)
3
+ --SKIPIF--
4
+ <?php
5
+ if (!extension_loaded ("zlib " )) {
6
+ print "skip - ZLIB extension not loaded " ;
7
+ }
8
+ ?>
9
+ --FILE--
10
+ <?php
11
+
12
+ ini_set ('memory_limit ' , '64M ' );
13
+
14
+ $ deflator = deflate_init (ZLIB_ENCODING_RAW );
15
+
16
+ $ bytes = str_repeat ("* " , 65536 );
17
+
18
+ // this crashes after about 500 iterations if PHP is
19
+ // configured for 64M
20
+ for ($ i = 0 ; $ i < 1000 ; $ i ++) {
21
+ $ output = deflate_add (
22
+ $ deflator ,
23
+ $ bytes ,
24
+ ZLIB_SYNC_FLUSH
25
+ );
26
+ }
27
+ echo "Completed \n" ;
28
+ ?>
29
+ --EXPECT--
30
+ Completed
Original file line number Diff line number Diff line change @@ -1154,10 +1154,8 @@ PHP_FUNCTION(deflate_add)
1154
1154
RETURN_EMPTY_STRING ();
1155
1155
}
1156
1156
1157
- out_size = PHP_ZLIB_BUFFER_SIZE_GUESS (ctx -> total_in + in_len );
1158
- out_size = (ctx -> total_out >= out_size ) ? 16 : (out_size - ctx -> total_out );
1159
- out_size = (out_size < 16 ) ? 16 : out_size ;
1160
- out_size += 64 ;
1157
+ out_size = PHP_ZLIB_BUFFER_SIZE_GUESS (in_len );
1158
+ out_size = (out_size < 64 ) ? 64 : out_size ;
1161
1159
out = zend_string_alloc (out_size , 0 );
1162
1160
1163
1161
ctx -> next_in = (Bytef * ) in_buf ;
You can’t perform that action at this time.
0 commit comments