shithub: mc

Download patch

ref: f6d4fa4780350777e7446258997ffd7b9217a84a
parent: 9676f65ff1660a8ebc47b384ba056717e6cde056
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jan 19 20:03:50 EST 2016

Pass correct size of sockaddr type.

	If ipv6 is going to work, bytewe need to pass the right size,
	in the branching.

--- a/lib/std/dial+posixy.myr
+++ b/lib/std/dial+posixy.myr
@@ -34,7 +34,7 @@
 	var sa4 : sys.sockaddr_in
 	var sa6 : sys.sockaddr_in6
 	var sa	: sys.sockaddr#
-	var sock
+	var sock, sz
 
 	match parsedial(str)
 	| `Ok val:	(proto, host, port) = val
@@ -49,6 +49,7 @@
 			.port = hosttonet(port),
 		]
 		sa = &sa4 castto(sys.sockaddr#)
+		sz = sizeof(sys.sockaddr_in)
 	| `Ipv6 bits:
 		sa6 = [
 			.fam = sys.Afinet6,
@@ -56,6 +57,7 @@
 			.port = hosttonet(port),
 		]
 		sa = &sa6 castto(sys.sockaddr#)
+		sz = sizeof(sys.sockaddr_in6)
 	;;
 	sock = sys.socket(2, proto, 0)
 
@@ -63,7 +65,7 @@
 		-> `Fail "failed to connect to socket"
 	;;
 	var err
-	err = sys.connect(sock, sa, sizeof(sys.sockaddr_in))
+	err = sys.connect(sock, sa, sz)
 	if err < 0
 		sys.close(sock)
 		-> `Fail "Failed to bind socket"