diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-25 20:58:17 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-25 20:58:17 +0100 |
| commit | 3f7d4f4e8bc8cd9928fd0b1b280eb4c3f0ca9fa5 (patch) | |
| tree | f3d220141f1aa8a4573a3166d78fa77f71e9b40e /ot_http.c | |
| parent | fe327bf9ea78281e39e732e242f210015bc39d8f (diff) | |
Prevent UAF when resizing iobatches
Diffstat (limited to 'ot_http.c')
| -rw-r--r-- | ot_http.c | 7 |
1 files changed, 5 insertions, 2 deletions
| @@ -216,11 +216,14 @@ ssize_t http_sendiovecdata(const int64_t sock, struct ot_workstruct *ws, size_t | |||
| 216 | /* If the current batch's limit is reached, try to reallocate a new batch to work on */ | 216 | /* If the current batch's limit is reached, try to reallocate a new batch to work on */ |
| 217 | if (current->bytesleft > OT_BATCH_LIMIT) { | 217 | if (current->bytesleft > OT_BATCH_LIMIT) { |
| 218 | io_batch *new_batch = realloc(cookie->batch, (cookie->batches + 1) * sizeof(io_batch)); | 218 | io_batch *new_batch = realloc(cookie->batch, (cookie->batches + 1) * sizeof(io_batch)); |
| 219 | |||
| 219 | if (new_batch) { | 220 | if (new_batch) { |
| 220 | cookie->batch = new_batch; | 221 | cookie->batch = new_batch; |
| 221 | if (OT_IOB_INIT(current) != -1) | 222 | if (OT_IOB_INIT(cookie->batch + cookie->batches) != -1) |
| 222 | current = cookie->batch + cookie->batches++; | 223 | ++cookie->batches; |
| 223 | } | 224 | } |
| 225 | /* realloc may have moved the batches, so current is stale either way */ | ||
| 226 | current = cookie->batch + cookie->batches - 1; | ||
| 224 | } | 227 | } |
| 225 | iob_addbuf_free(current, iovector[i].iov_base, iovector[i].iov_len); | 228 | iob_addbuf_free(current, iovector[i].iov_base, iovector[i].iov_len); |
| 226 | } | 229 | } |
