mirror of
https://github.com/fluencelabs/redis
synced 2025-03-18 16:40:50 +00:00
Fix potential invalid read past end of array
If array has N elements, we can't read +1 if we are already at N. Also, we need to move elements by their storage size in the array, not just by individual bytes.
This commit is contained in:
parent
30152554ea
commit
29049507ec
@ -783,8 +783,11 @@ int clusterNodeRemoveSlave(clusterNode *master, clusterNode *slave) {
|
||||
|
||||
for (j = 0; j < master->numslaves; j++) {
|
||||
if (master->slaves[j] == slave) {
|
||||
memmove(master->slaves+j,master->slaves+(j+1),
|
||||
(master->numslaves-1)-j);
|
||||
if ((j+1) < master->numslaves) {
|
||||
int remaining_slaves = (master->numslaves - j) - 1;
|
||||
memmove(master->slaves+j,master->slaves+(j+1),
|
||||
(sizeof(*master->slaves) * remaining_slaves));
|
||||
}
|
||||
master->numslaves--;
|
||||
return REDIS_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user