Commit 3ac3082
fix(FormData): throw error instead of crashing on very large input
When `FormData.from()` is called with a very large ArrayBuffer (exceeding
WebKit's String::MaxLength of INT32_MAX), it would crash with an assertion
failure in WebKit's StringImpl. This fixes the issue by:
1. Adding a length check in the C++ `toString` function (helpers.h) for
UTF8-tagged strings to check against both Bun's synthetic limit and
WebKit's String::MaxLength before attempting to create the string.
2. Adding a length check in the Zig `FormData.toJS` function to throw a
proper error message before attempting to create the string.
Now `FormData.from(new Uint32Array(913148244))` throws a proper JavaScript
error instead of crashing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent ddcec61 commit 3ac3082
File tree
3 files changed
+26
-1
lines changed- src
- bun.js/bindings
- test/js/web/html
3 files changed
+26
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
983 | 983 | | |
984 | 984 | | |
985 | 985 | | |
986 | | - | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
987 | 992 | | |
988 | 993 | | |
989 | 994 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
280 | 295 | | |
281 | 296 | | |
282 | 297 | | |
| |||
0 commit comments