Repository navigation
Commit 32a1fe5
fix: guard repeat array length overflow (apache#22293)
## Which issue does this PR close?
- Closes apache#22217.
## Rationale for this change
The array execution path for `repeat(string, count)` calculated
`string.len() * count` before checking the configured string-size limit.
For very large counts, that multiplication can overflow and panic
instead of returning the same string-size overflow error used by the
scalar path.
## What changes are included in this PR?
- Adds checked count conversion and repeated-length calculation helpers.
- Uses checked multiplication and checked total-capacity accumulation in
the array path.
- Adds Rust and sqllogictest coverage for the one-row columnar
reproducer from the issue.
## Are these changes tested?
- `cargo fmt --all`
- `TMPDIR=/home/sean/Projects/datafusion-repeat-overflow/target/tmp
cargo test -p datafusion-functions
string::repeat::tests::test_repeat_string_array_overflow -- --nocapture`
- `TMPDIR=/home/sean/Projects/datafusion-repeat-overflow/target/tmp
cargo test --profile=ci --test sqllogictests --
string/string_literal.slt`
- `TMPDIR=/home/sean/Projects/datafusion-repeat-overflow/target/tmp
cargo clippy --all-targets --all-features -- -D warnings`
- `git diff --check`
## Are there any user-facing changes?
Invalid oversized `repeat` results in the columnar path now return a
normal DataFusion string-size overflow error instead of panicking.
---------
Co-authored-by: Andrew Lamb <[email protected]>1 parent 34834dc commit 32a1fe5
2 files changed
Lines changed: 57 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
169 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
170 | 186 | | |
171 | 187 | | |
172 | 188 | | |
173 | 189 | | |
174 | 190 | | |
175 | 191 | | |
176 | 192 | | |
177 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
178 | 205 | | |
179 | 206 | | |
180 | 207 | | |
| |||
227 | 254 | | |
228 | 255 | | |
229 | 256 | | |
230 | | - | |
231 | | - | |
| 257 | + | |
| 258 | + | |
232 | 259 | | |
233 | 260 | | |
234 | 261 | | |
235 | 262 | | |
236 | 263 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
246 | 273 | | |
247 | 274 | | |
248 | 275 | | |
| |||
487 | 514 | | |
488 | 515 | | |
489 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
490 | 529 | | |
491 | 530 | | |
492 | 531 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
394 | 398 | | |
395 | 399 | | |
396 | 400 | | |
| |||
0 commit comments