From owner-freebsd-hackers Tue Jan 8 4:39:29 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mail11.speakeasy.net (mail11.speakeasy.net [216.254.0.211]) by hub.freebsd.org (Postfix) with ESMTP id 6F41437B41B for ; Tue, 8 Jan 2002 04:39:03 -0800 (PST) Received: (qmail 1209 invoked from network); 8 Jan 2002 12:39:02 -0000 Received: from unknown (HELO server.baldwin.cx) ([64.81.54.73]) (envelope-sender ) by mail11.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 8 Jan 2002 12:39:02 -0000 Received: from laptop.baldwin.cx (root@laptop.baldwin.cx [192.168.0.4]) by server.baldwin.cx (8.11.6/8.11.6) with ESMTP id g08BCxK51603; Tue, 8 Jan 2002 03:12:59 -0800 (PST) (envelope-from john@laptop.baldwin.cx) Received: (from john@localhost) by laptop.baldwin.cx (8.11.6/8.11.6) id g08BCRi00686; Tue, 8 Jan 2002 03:12:27 -0800 (PST) (envelope-from john) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Date: Tue, 08 Jan 2002 03:12:26 -0800 (PST) From: John Baldwin To: wpaul@FreeBSD.org, hackers@FreeBSD.org Subject: [PATCH] Fix endianness bug in YP Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG YP didn't work on my sparc64 testbox here until I crafted this patch. It's a simple combination of an endian problem on an arch where sizeof(long) != sizeof(IPv4 address). The patch can be found at http://www.freebsd.org/~jhb/patches/yp.patch and below: I've tested it on both sparc64 and i386. Both work fine. sparc64 didn't work prior to this. Unfortunately, my mailer is going to butcher it, so you probably want to fetch the version above. I'd like to commit it unless there are objections. Index: yplib.c =================================================================== RCS file: /usr/cvs/src/lib/libc/yp/yplib.c,v retrieving revision 1.36 diff -u -r1.36 yplib.c --- yplib.c 23 May 2001 15:37:10 -0000 1.36 +++ yplib.c 8 Jan 2002 10:30:39 -0000 @@ -402,10 +402,12 @@ 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 @@ 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 -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message