Skip to content

Commit

Permalink
Merge branch 'PHP-8.4'
Browse files Browse the repository at this point in the history
* PHP-8.4:
  Fixed phpGH-16978: Avoid unnecessary padding with leading zeros (php#16988)
  • Loading branch information
SakiTakamachi committed Nov 29, 2024
2 parents 2473f57 + d17ed34 commit 5930278
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/bcmath/libbcmath/src/div.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ bool bc_divide(bc_num numerator, bc_num divisor, bc_num *quot, size_t scale)
numerator_bottom_extension = 0;
numeratorend -= scale_diff > numerator_top_extension ? scale_diff - numerator_top_extension : 0;
}
numerator_top_extension = MIN(numerator_top_extension, scale);
} else {
numerator_bottom_extension += scale - numerator_scale;
}
Expand Down
12 changes: 12 additions & 0 deletions ext/bcmath/tests/gh16978.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
GH-16978 Stack buffer overflow ext/bcmath/libbcmath/src/div.c:464:12 in bc_divide
--EXTENSIONS--
bcmath
--FILE--
<?php
echo bcpow('10', '-112', 10) . "\n";
echo bcdiv('1', '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 1);
?>
--EXPECT--
0.0000000000
0.0

0 comments on commit 5930278

Please sign in to comment.