Skip to content

Commit

Permalink
Fix use after free replication data block
Browse files Browse the repository at this point in the history
During replStreamProgressCallback replica may recive replicaof command
and hance free replica side replicaiton buffer. If replication buffer is
freed we should abort the streaming

Signed-off-by: naglera <[email protected]>
  • Loading branch information
naglera committed Jun 10, 2024
1 parent 0fa3260 commit 15905e7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -2942,6 +2942,11 @@ void streamReplDataBufToDb(client *c) {
processInputBuffer(c);
server.pending_repl_data.len -= o->used;
replStreamProgressCallback(offset, o->used, &last_progress_callback);
if (!server.pending_repl_data.blocks) {
/* If we processed replicaof command during replStreamProgressCallback, then
* we should abort replication data streaming ASAP. */
break;
}
offset += o->used;
listDelNode(server.pending_repl_data.blocks, cur);
}
Expand Down

0 comments on commit 15905e7

Please sign in to comment.