Commit f315d5e
committed
LibJS: Reject repeat counts above 2^53 - 1 in
Converting the maximum size_t value to a double rounds up to 2^64, so
a count of exactly 2^64 passed the range check and was subsequently
converted to an unsigned type, which is undefined behavior. Compare
against the maximum array-like index instead, which is exactly
representable as a double. Any count above that limit necessarily
exceeds the maximum string length, so it is rejected in any case.String.prototype.repeat
1 parent 6cca2b9 commit f315d5e
2 files changed
Lines changed: 5 additions & 1 deletion
File tree
- Libraries/LibJS/Runtime
- Tests/LibJS/Runtime/builtins/String
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
824 | 824 | | |
825 | 825 | | |
826 | 826 | | |
827 | | - | |
| 827 | + | |
828 | 828 | | |
829 | 829 | | |
830 | 830 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
0 commit comments