qrexec-daemon: fix read underflow when the last fd goes
If no remaining fd is alive in the list, the loop breaks when i is negative, but by then clients[-1] would have been dereferenced.
This commit is contained in:
parent
bac950c5ce
commit
771be64912
@ -246,7 +246,7 @@ void terminate_client_and_flush_data(int fd)
|
|||||||
clients[fd].state = CLIENT_INVALID;
|
clients[fd].state = CLIENT_INVALID;
|
||||||
buffer_free(&clients[fd].buffer);
|
buffer_free(&clients[fd].buffer);
|
||||||
if (max_client_fd == fd) {
|
if (max_client_fd == fd) {
|
||||||
for (i = fd; clients[i].state == CLIENT_INVALID && i >= 0;
|
for (i = fd; i >= 0 && clients[i].state == CLIENT_INVALID;
|
||||||
i--);
|
i--);
|
||||||
max_client_fd = i;
|
max_client_fd = i;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user