[PATCH] Fix xdr_long and xdr_u_long
Jakub Jelinek
jakub@redhat.com
Wed Jan 3 03:44:00 GMT 2001
Hi!
xdr_long and xdr_u_long silently discard upper bits on 64bit arches, they
should fail instead.
2001-01-03 Jakub Jelinek <jakub@redhat.com>
* sunrpc/xdr.c (xdr_long, xdr_u_long): Return FALSE if trying to
encode value which does not fit in the 32bit type.
--- libc/sunrpc/xdr.c.jj Sat Jul 15 18:45:26 2000
+++ libc/sunrpc/xdr.c Wed Jan 3 12:31:41 2001
@@ -159,7 +159,9 @@ bool_t
xdr_long (XDR *xdrs, long *lp)
{
- if (xdrs->x_op == XDR_ENCODE)
+ if (xdrs->x_op == XDR_ENCODE
+ && (sizeof (int32_t) == sizeof (long)
+ || (int32_t) *lp == *lp))
return XDR_PUTLONG (xdrs, lp);
if (xdrs->x_op == XDR_DECODE)
@@ -192,6 +194,10 @@ xdr_u_long (XDR *xdrs, u_long *ulp)
}
case XDR_ENCODE:
+ if (sizeof (uint32_t) != sizeof (u_long)
+ && (uint32_t) *ulp != *ulp)
+ return FALSE;
+
return XDR_PUTLONG (xdrs, (long *) ulp);
case XDR_FREE:
Jakub
More information about the Libc-hacker
mailing list