[CRIU] [PATCH] cr_page_server(): avoid using uninit variable
Kir Kolyshkin
kir at openvz.org
Tue May 5 15:25:21 PDT 2015
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 at openvz.org>
---
page-xfer.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/page-xfer.c b/page-xfer.c
index 8fff767..dc7e815 100644
--- a/page-xfer.c
+++ b/page-xfer.c
@@ -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);
--
1.9.3
More information about the CRIU
mailing list