summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2005-10-30 19:44:53 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2005-10-30 19:44:53 +0000
commitca05097b98440835495e82aa7e6818085ab4e93e (patch)
tree5f0b297e97a76dbb7267d59442d2c5038e915784 /lib/libc
parent9cd1b00c1ec1fb7226fa779ee8c7581c457fe486 (diff)
Make xdrstdio_getlong() and xdrstdio_putlong() work on 64-bit big-endian
systems. From NetBSD and FreeBSD. ok deraadt@, otto@, "looks correct to me" fgsch@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/rpc/xdr_stdio.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/libc/rpc/xdr_stdio.c b/lib/libc/rpc/xdr_stdio.c
index a27f3a1468a..f60c50ef79b 100644
--- a/lib/libc/rpc/xdr_stdio.c
+++ b/lib/libc/rpc/xdr_stdio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xdr_stdio.c,v 1.8 2005/08/08 08:05:36 espie Exp $ */
+/* $OpenBSD: xdr_stdio.c,v 1.9 2005/10/30 19:44:52 kettenis Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -95,21 +95,20 @@ xdrstdio_destroy(XDR *xdrs)
static bool_t
xdrstdio_getlong(XDR *xdrs, long int *lp)
{
+ u_int32_t temp;
- if (fread((caddr_t)lp, sizeof(int32_t), 1,
- (FILE *)xdrs->x_private) != 1)
+ if (fread(&temp, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1)
return (FALSE);
- *lp = (long)ntohl((u_int32_t)*lp);
+ *lp = (long)ntohl(temp);
return (TRUE);
}
static bool_t
xdrstdio_putlong(XDR *xdrs, long int *lp)
{
- long mycopy = (long)htonl((u_int32_t)*lp);
+ int32_t mycopy = htonl((u_int32_t)*lp);
- if (fwrite((caddr_t)&mycopy, sizeof(int32_t), 1,
- (FILE *)xdrs->x_private) != 1)
+ if (fwrite(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1)
return (FALSE);
return (TRUE);
}