File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed
Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ PHP NEWS
22|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33?? ??? ????, PHP 8.3.30
44
5+ - Bz2:
6+ . Fixed bug GH-20620 (bzcompress overflow on large source size).
7+ (David Carlier)
8+
59- GD:
610 . Fixed bug GH-20622 (imagestring/imagestringup overflow). (David Carlier)
711
Original file line number Diff line number Diff line change @@ -459,7 +459,15 @@ PHP_FUNCTION(bzcompress)
459459 + .01 x length of data + 600 which is the largest size the results of the compression
460460 could possibly be, at least that's what the libbz2 docs say (thanks to jeremy@nirvani.net
461461 for pointing this out). */
462- dest_len = (unsigned int ) (source_len + (0.01 * source_len ) + 600 );
462+ size_t chunk_len = source_len + source_len / 100 + 600 ;
463+ const size_t min = MIN (ZSTR_MAX_LEN , UINT_MAX );
464+
465+ if (chunk_len < source_len || chunk_len > min ) {
466+ zend_argument_value_error (1 , "must have a length less than or equal to %zu" , min );
467+ RETURN_THROWS ();
468+ }
469+
470+ dest_len = (unsigned int ) chunk_len ;
463471
464472 /* Allocate the destination buffer */
465473 dest = zend_string_alloc (dest_len , 0 );
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Bug GH-20620 (bzcompress with large source)
3+ --EXTENSIONS--
4+ bz2
5+ --SKIPIF--
6+ <?php
7+ if (PHP_INT_SIZE != 8 ) die ('skip this test is for 64bit platforms only ' );
8+ if (getenv ('SKIP_SLOW_TESTS ' )) die ('skip slow tests excluded by request ' );
9+ ?>
10+ --INI--
11+ memory_limit=-1
12+ --FILE--
13+ <?php
14+ try {
15+ bzcompress (str_repeat ('1 ' , 4295163906 ));
16+ } catch (\ValueError $ e ) {
17+ echo $ e ->getMessage (), PHP_EOL ;
18+ }
19+ ?>
20+ --EXPECTF--
21+ bzcompress(): Argument #1 ($data) must have a length less than or equal to %d
You can’t perform that action at this time.
0 commit comments