Better to refuse longer inputs than doing something weird in the compression code.
Unified · Split
| @@ -284,6 +284,14 @@ static size_t write_samples(sox_format_t * ft, const sox_sample_t *buf, size_t l · 283 unmodified lines | ||
| 284 | 284 | if (len == 0) |
| 285 | 285 | return 0; |
| 286 | 286 | |
| 287 | + if (p->pos == INT32_MAX) | |
| 288 | + return SOX_EOF; | |
| 289 | + | |
| 290 | + if (p->pos + len > INT32_MAX) { | |
| 291 | + lsx_warn("maximum file size exceeded"); | |
| 292 | + len = INT32_MAX - p->pos; | |
| 293 | + } | |
| 294 | + | |
| 287 | 295 | if (p->pos + len > p->size) { |
| 288 | 296 | p->size = ((p->pos + len) / BUFINCR + 1) * BUFINCR; |
| 289 | 297 | p->data = lsx_realloc(p->data, p->size); |