Skip to content

Commit

Permalink
iproto: fix use-after-free in net_end_join
Browse files Browse the repository at this point in the history
`msg` is used after it is freed in iproto_msg_delete.

Close #9037

NO_TEST=tested by ASAN
NO_DOC=bugfix
  • Loading branch information
nshy authored and locker committed Aug 28, 2023
1 parent 22e1532 commit 4916389
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelogs/unreleased/gh-9037-fix-heap-use-after-free.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## bugfix/core

* Fixed a use-after-free bug in iproto server code (gh-9037).
5 changes: 3 additions & 2 deletions src/box/iproto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2669,16 +2669,17 @@ net_end_join(struct cmsg *m)
{
struct iproto_msg *msg = (struct iproto_msg *) m;
struct iproto_connection *con = msg->connection;
struct ibuf *ibuf = msg->p_ibuf;

msg->p_ibuf->rpos += msg->len;
ibuf->rpos += msg->len;
iproto_msg_delete(msg);

assert(! ev_is_active(&con->input));
/*
* Enqueue any messages if they are in the readahead
* queue. Will simply start input otherwise.
*/
if (iproto_enqueue_batch(con, msg->p_ibuf) != 0)
if (iproto_enqueue_batch(con, ibuf) != 0)
iproto_connection_close(con);
}

Expand Down

0 comments on commit 4916389

Please sign in to comment.