[CRIU] [PATCH 1/2] sk-inet: More detailed error parsing on
unconnected socket
Cyrill Gorcunov
gorcunov at openvz.org
Tue Oct 30 10:47:27 EDT 2012
errno is no guaranteed to be clear if call exit with
success. Thus make sure we've ret negative here and
test for errno then.
http://bugzilla.openvz.org/show_bug.cgi?id=2412
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
sk-inet.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/sk-inet.c b/sk-inet.c
index 6382bd5..500aa63 100644
--- a/sk-inet.c
+++ b/sk-inet.c
@@ -167,8 +167,13 @@ static struct inet_sk_desc *gen_uncon_sk(int lfd, const struct fd_parms *p)
/* It should has no peer name */
aux = sizeof(address);
ret = getsockopt(lfd, SOL_SOCKET, SO_PEERNAME, address, &aux);
- if (ret != -1 || errno != ENOTCONN) {
- pr_err("Errno %d returned from unconnected socket\n", errno);
+ if (ret < 0) {
+ if (errno != ENOTCONN) {
+ pr_perror("Unexpected error returned from unconnected socket");
+ goto err;
+ }
+ } else if (ret == 0) {
+ pr_err("Name resolved on unconnected socket\n");
goto err;
}
--
1.7.7.6
More information about the CRIU
mailing list