Skip to content

Commit 5ee8248

Browse files
Sashant8m
authored andcommitted
ossl_rio_poll_builder_add_fd(): Fixup pfds after reallocation
Local variable `pfds` used in `ossl_rio_poll_builder_add_fd()` must be consistent with `rpb->pfd_heap`. The function maintains array of SSL objects for SSL_poll(3ossl). It works with no issues until we need to reallocate `rbp->pfd_heap` in `rpb_ensure_alloc()`. After `rpb_ensure_alloc()` returns we must update local variable `pfds` with `rpb->pfd_heap` not doing so makes function to write to dead buffer. Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from openssl#27804)
1 parent de1e498 commit 5ee8248

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ssl/rio/poll_builder.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,11 @@ int ossl_rio_poll_builder_add_fd(RIO_POLL_BUILDER *rpb, int fd,
115115
if (i >= rpb->pfd_alloc) {
116116
if (!rpb_ensure_alloc(rpb, rpb->pfd_alloc * 2))
117117
return 0;
118+
pfds = rpb->pfd_heap;
118119
}
119120

121+
assert((rpb->pfd_heap != NULL && rpb->pfd_heap == pfds) ||
122+
(rpb->pfd_heap == NULL && rpb->pfds == pfds));
120123
assert(i <= rpb->pfd_num && rpb->pfd_num <= rpb->pfd_alloc);
121124
pfds[i].fd = fd;
122125
pfds[i].events = 0;

0 commit comments

Comments
 (0)