File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -455,11 +455,18 @@ PHP_FUNCTION(bzcompress)
455455 RETURN_THROWS ();
456456 }
457457
458+ size_t chunk_len = source_len + (0.01 * source_len ) + 600 ;
459+
460+ if (chunk_len < source_len || chunk_len > UINT_MAX ) {
461+ zend_argument_value_error (1 , "must be less than or equal to %lu" , UINT_MAX );
462+ RETURN_THROWS ();
463+ }
464+
458465 /* Assign them to easy to use variables, dest_len is initially the length of the data
459466 + .01 x length of data + 600 which is the largest size the results of the compression
460467 could possibly be, at least that's what the libbz2 docs say (thanks to jeremy@nirvani.net
461468 for pointing this out). */
462- dest_len = (unsigned int ) ( source_len + ( 0.01 * source_len ) + 600 ) ;
469+ dest_len = (unsigned int ) chunk_len ;
463470
464471 /* Allocate the destination buffer */
465472 dest = zend_string_alloc (dest_len , 0 );
You can’t perform that action at this time.
0 commit comments