|
| 1 | +--TEST-- |
| 2 | +bcmath strings with embedded null bytes must be rejected as not well-formed |
| 3 | +--EXTENSIONS-- |
| 4 | +bcmath |
| 5 | +--FILE-- |
| 6 | +<?php |
| 7 | +$cases = [ |
| 8 | + "100\x005", |
| 9 | + "1.2\x003", |
| 10 | + "\x00123", |
| 11 | +]; |
| 12 | + |
| 13 | +$calls = [ |
| 14 | + fn($s) => bcadd($s, "0"), |
| 15 | + fn($s) => bcsub($s, "0"), |
| 16 | + fn($s) => bcmul($s, "1"), |
| 17 | + fn($s) => bcdiv($s, "1"), |
| 18 | + fn($s) => bcmod($s, "7"), |
| 19 | + fn($s) => bcpow($s, "1"), |
| 20 | + fn($s) => bccomp($s, "0"), |
| 21 | + fn($s) => bcsqrt($s), |
| 22 | +]; |
| 23 | + |
| 24 | +foreach ($cases as $s) { |
| 25 | + foreach ($calls as $fn) { |
| 26 | + try { |
| 27 | + $fn($s); |
| 28 | + echo "FAIL: accepted\n"; |
| 29 | + } catch (\ValueError $e) { |
| 30 | + echo $e->getMessage() . "\n"; |
| 31 | + } |
| 32 | + } |
| 33 | +} |
| 34 | +?> |
| 35 | +--EXPECT-- |
| 36 | +bcadd(): Argument #1 ($num1) is not well-formed |
| 37 | +bcsub(): Argument #1 ($num1) is not well-formed |
| 38 | +bcmul(): Argument #1 ($num1) is not well-formed |
| 39 | +bcdiv(): Argument #1 ($num1) is not well-formed |
| 40 | +bcmod(): Argument #1 ($num1) is not well-formed |
| 41 | +bcpow(): Argument #1 ($num) is not well-formed |
| 42 | +bccomp(): Argument #1 ($num1) is not well-formed |
| 43 | +bcsqrt(): Argument #1 ($num) is not well-formed |
| 44 | +bcadd(): Argument #1 ($num1) is not well-formed |
| 45 | +bcsub(): Argument #1 ($num1) is not well-formed |
| 46 | +bcmul(): Argument #1 ($num1) is not well-formed |
| 47 | +bcdiv(): Argument #1 ($num1) is not well-formed |
| 48 | +bcmod(): Argument #1 ($num1) is not well-formed |
| 49 | +bcpow(): Argument #1 ($num) is not well-formed |
| 50 | +bccomp(): Argument #1 ($num1) is not well-formed |
| 51 | +bcsqrt(): Argument #1 ($num) is not well-formed |
| 52 | +bcadd(): Argument #1 ($num1) is not well-formed |
| 53 | +bcsub(): Argument #1 ($num1) is not well-formed |
| 54 | +bcmul(): Argument #1 ($num1) is not well-formed |
| 55 | +bcdiv(): Argument #1 ($num1) is not well-formed |
| 56 | +bcmod(): Argument #1 ($num1) is not well-formed |
| 57 | +bcpow(): Argument #1 ($num) is not well-formed |
| 58 | +bccomp(): Argument #1 ($num1) is not well-formed |
| 59 | +bcsqrt(): Argument #1 ($num) is not well-formed |
0 commit comments