summaryrefslogtreecommitdiffstats
path: root/lib/libc/yp
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2002-01-08 18:05:03 +0000
committerjhb <jhb@FreeBSD.org>2002-01-08 18:05:03 +0000
commit6e3fd0986046e2fc1d552a3b4c4e869d4e5a5c04 (patch)
tree181b8015fb8d6603e624e6872bd46f03a5c26aa9 /lib/libc/yp
parent4749f2659853a5d78e100a6eeff3804b56694e7e (diff)
downloadFreeBSD-src-6e3fd0986046e2fc1d552a3b4c4e869d4e5a5c04.zip
FreeBSD-src-6e3fd0986046e2fc1d552a3b4c4e869d4e5a5c04.tar.gz
Fix some 32/64-bit bugs. IPv4 addresses are 32-bits, not longs. On the
alpha these bugs didn't cause any problems because it was little endian, but on sparc64, we ended up with garbage for the IP address when we tried to contact the server. (Usually 3.253.0.0) Not objected to by: wpaul
Diffstat (limited to 'lib/libc/yp')
-rw-r--r--lib/libc/yp/yplib.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/libc/yp/yplib.c b/lib/libc/yp/yplib.c
index 4a8a896..9619bdc 100644
--- a/lib/libc/yp/yplib.c
+++ b/lib/libc/yp/yplib.c
@@ -402,10 +402,12 @@ again:
bzero(&ysd->dom_server_addr, sizeof ysd->dom_server_addr);
ysd->dom_server_addr.sin_family = AF_INET;
ysd->dom_server_addr.sin_len = sizeof(struct sockaddr_in);
- ysd->dom_server_addr.sin_addr.s_addr =
- *(u_long *)&ybr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr;
- ysd->dom_server_addr.sin_port =
- *(u_short *)&ybr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port;
+ bcopy(&ybr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr,
+ &ysd->dom_server_addr.sin_addr.s_addr,
+ sizeof(ysd->dom_server_addr.sin_addr.s_addr));
+ bcopy(&ybr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port,
+ &ysd->dom_server_addr.sin_port,
+ sizeof(ysd->dom_server_addr.sin_port));
ysd->dom_server_port = ysd->dom_server_addr.sin_port;
_close(fd);
@@ -497,10 +499,12 @@ skipit:
bzero((char *)&ysd->dom_server_addr, sizeof ysd->dom_server_addr);
ysd->dom_server_addr.sin_family = AF_INET;
- ysd->dom_server_addr.sin_port =
- *(u_short *)&ypbr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port;
- ysd->dom_server_addr.sin_addr.s_addr =
- *(u_long *)&ypbr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr;
+ bcopy(&ypbr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port,
+ &ysd->dom_server_addr.sin_port,
+ sizeof(ysd->dom_server_addr.sin_port));
+ bcopy(&ypbr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr,
+ &ysd->dom_server_addr.sin_addr.s_addr,
+ sizeof(ysd->dom_server_addr.sin_addr.s_addr));
/*
* We could do a reserved port check here too, but this
OpenPOWER on IntegriCloud