summaryrefslogtreecommitdiff
path: root/ot_http.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-25 20:58:17 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-10-25 20:58:17 +0100
commit3f7d4f4e8bc8cd9928fd0b1b280eb4c3f0ca9fa5 (patch)
treef3d220141f1aa8a4573a3166d78fa77f71e9b40e /ot_http.c
parentfe327bf9ea78281e39e732e242f210015bc39d8f (diff)
Prevent UAF when resizing iobatches
Diffstat (limited to 'ot_http.c')
-rw-r--r--ot_http.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ot_http.c b/ot_http.c
index fc27eb8..4c4121b 100644
--- a/ot_http.c
+++ b/ot_http.c
@@ -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 }