2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

cr_page_server(): avoid using uninit variable

In case opts.ps_socket is set (see commit 7058714),
we don't call accept() and so the peer address (caddr)
is left uninitialized, but we try to print it.

Fix by moving the printing code to right after accept().

Reported by Coverity, CID 51645.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Kir Kolyshkin
2015-05-06 01:25:00 +03:00
committed by Pavel Emelyanov
parent 2403ee4695
commit 1e919423a8

View File

@@ -354,17 +354,15 @@ no_server:
ret = ask = accept(sk, (struct sockaddr *)&caddr, &clen);
if (ask < 0)
pr_perror("Can't accept connection to server");
else
pr_info("Accepted connection from %s:%u\n",
inet_ntoa(caddr.sin_addr),
(int)ntohs(caddr.sin_port));
close(sk);
}
if (ask >= 0) {
pr_info("Accepted connection from %s:%u\n",
inet_ntoa(caddr.sin_addr),
(int)ntohs(caddr.sin_port));
if (ask >= 0)
ret = page_server_serve(ask);
}
if (daemon_mode)
exit(ret);