• Binbin's avatar
    Fix PSYNC crash with wrong offset (#10243) · 344e41c9
    Binbin authored
    `PSYNC replicationid str_offset` will crash the server.
    
    The reason is in `masterTryPartialResynchronization`,
    we will call `getLongLongFromObjectOrReply` check the
    offset. With a wrong offset, it will add a reply and
    then trigger a full SYNC and the client become a replica.
    
    So crash in `c->bufpos == 0 && listLength(c->reply) == 0`.
    In this commit, we check the psync_offset before entering
    function `masterTryPartialResynchronization`, and return.
    
    Regardless of that crash, accepting the sync, but also replying
    with an error would have corrupt the replication stream.
    344e41c9
replication.c 162 KB