[CRIU] [crtools-bot] sockets: Datagram connection fix

Cyrill Gorcunov gorcunov at openvz.org
Tue Feb 7 08:26:43 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
--------------->
commit aeabf03133230d55285ca0536bbf94ea43ea62d4
Author: Pavel Emelyanov <xemul at parallels.com>
Date:   Tue Feb 7 15:50:00 2012 +0400

    sockets: Datagram connection fix
    
    The address length should be the real length, not the buffer size.
    
    Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
    Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 sockets.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/sockets.c b/sockets.c
index 14bad10..b0d7206 100644
--- a/sockets.c
+++ b/sockets.c
@@ -756,6 +756,7 @@ static void prep_conn_addr(int id, struct sockaddr_un *addr, int *addrlen)
 struct unix_dgram_bound {
 	struct unix_dgram_bound	*next;
 	struct sockaddr_un	addr;
+	int			addr_len;
 	int			id;
 };
 
@@ -783,7 +784,7 @@ static int run_connect_jobs_dgram(void)
 			goto err;
 		}
 
-		if (connect(d->fd, (struct sockaddr *)&b->addr, sizeof(b->addr)) < 0) {
+		if (connect(d->fd, (struct sockaddr *)&b->addr, b->addr_len) < 0) {
 			pr_perror("Can't connect peer %d on fd %d",
 				  d->peer, d->fd);
 			goto err;
@@ -852,6 +853,7 @@ static int open_unix_sk_dgram(int sk, struct unix_sk_entry *ue, int img_fd)
 			goto err;
 
 		memcpy(&d->addr, &addr, sizeof(d->addr));
+		d->addr_len = sizeof(addr.sun_family) + ue->namelen;
 		d->id	= ue->id;
 
 		SK_HASH_LINK(dgram_bound, d->id, d);


More information about the CRIU mailing list