Commit dfde6a1
authored
fix(builtins): clamp printf precision to prevent panic on large values (#1010)
## Summary
- Clamp user-controlled precision to 10000 in `FormatSpec::parse`
- Prevents thread panic when precision exceeds Rust's `format!` u16
limit (65535)
## What & Why
`printf "%.65536f" 1.0` caused a thread panic in Rust's `format!` macro,
dumping a full stack backtrace to stderr that leaks internal paths and
dependency versions. Now precision is clamped to a safe maximum (10000).
## Tests Added
- `test_large_precision_no_panic` — verifies no panic on precision >
65535
- `test_normal_precision_still_works` — verifies normal precision works
correctly
Closes #10031 parent 48dddc2 commit dfde6a1
1 file changed
+22
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| |||
137 | 140 | | |
138 | 141 | | |
139 | 142 | | |
140 | | - | |
| 143 | + | |
141 | 144 | | |
142 | 145 | | |
143 | 146 | | |
| |||
730 | 733 | | |
731 | 734 | | |
732 | 735 | | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
733 | 754 | | |
0 commit comments