qrexec: fix pending requests cleanup code

There was a logic error in pending requests cleanup code, causing
policy_pending_max being set to 0, even if there were more pending
requests. This effectively limited maximum pending requests to 1, after
some system uptime, because policy_pending_max set to 0 makes the code
looks only at the first pending request slot.

While at it, remove outdated FIXME comment, actually this bug is in the
code implementing this FIXME.

Fixes QubesOS/qubes-issues#2699
This commit is contained in:
Marek Marczykowski-Górecki 2017-03-13 03:10:39 +01:00
parent 452b6c4ae2
commit 723d32b8b7
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -608,8 +608,6 @@ static void reap_children()
pid_t pid; pid_t pid;
while ((pid=waitpid(-1, &status, WNOHANG)) > 0) { while ((pid=waitpid(-1, &status, WNOHANG)) > 0) {
/* FIXME: perhaps keep max(policy_pending) somewhere to optimize this
* search */
for (i = 0; i <= policy_pending_max; i++) { for (i = 0; i <= policy_pending_max; i++) {
if (policy_pending[i].pid == pid) { if (policy_pending[i].pid == pid) {
status = WEXITSTATUS(status); status = WEXITSTATUS(status);
@ -620,7 +618,7 @@ static void reap_children()
* MSG_SERVICE_CONNECT from client handler */ * MSG_SERVICE_CONNECT from client handler */
policy_pending[i].pid = 0; policy_pending[i].pid = 0;
while (policy_pending_max > 0 && while (policy_pending_max > 0 &&
policy_pending[policy_pending_max].pid > 0) policy_pending[policy_pending_max].pid == 0)
policy_pending_max--; policy_pending_max--;
break; break;
} }