summary refs log tree commit diff
path: root/sunrpc
diff options
context:
space:
mode:
Diffstat (limited to 'sunrpc')
-rw-r--r--sunrpc/rpc/types.h3
-rw-r--r--sunrpc/xdr.c49
-rw-r--r--sunrpc/xdr_mem.c2
-rw-r--r--sunrpc/xdr_rec.c4
-rw-r--r--sunrpc/xdr_stdio.c2
5 files changed, 51 insertions, 9 deletions
diff --git a/sunrpc/rpc/types.h b/sunrpc/rpc/types.h
index 1f620eff8f..032543f448 100644
--- a/sunrpc/rpc/types.h
+++ b/sunrpc/rpc/types.h
@@ -52,6 +52,9 @@ extern char *malloc();
 #include <sys/types.h>
 #endif
 #include <sys/time.h>
+#include <sys/param.h>
+
+#include <netinet/in.h>
 
 #ifndef INADDR_LOOPBACK
 #define       INADDR_LOOPBACK         (u_long)0x7F000001
diff --git a/sunrpc/xdr.c b/sunrpc/xdr.c
index a79db85b86..fccc2a5fe5 100644
--- a/sunrpc/xdr.c
+++ b/sunrpc/xdr.c
@@ -99,10 +99,30 @@ xdr_int(xdrs, ip)
 	(void) (xdr_short(xdrs, (short *)ip));
 	return (xdr_long(xdrs, (long *)ip));
 #else
-	if (sizeof (int) == 4) {
+	if (sizeof (int) < sizeof (long)) {
+		long l;
+
+		switch (xdrs->x_op) {
+		      case XDR_ENCODE:
+			l = (long) *ip;
+			return XDR_PUTLONG(xdrs, &l);
+
+		      case XDR_DECODE:
+			if (!XDR_GETLONG(xdrs, &l)) {
+				return FALSE;
+			}
+			*ip = (int) l;
+			return TRUE;
+		}
+	} else if (sizeof (int) == sizeof (long)) {
 		return (xdr_long(xdrs, (long *)ip));
-	} else {
+	} else if (sizeof (int) == sizeof (short)) {
 		return (xdr_short(xdrs, (short *)ip));
+	} else {
+		/* force unresolved reference (link-time error): */
+		extern unexpected_sizes_in_xdr_int ();
+
+		unexpected_sizes_in_xdr_int();
 	}
 #endif
 }
@@ -115,15 +135,34 @@ xdr_u_int(xdrs, up)
 	XDR *xdrs;
 	u_int *up;
 {
-
 #ifdef lint
 	(void) (xdr_short(xdrs, (short *)up));
 	return (xdr_u_long(xdrs, (u_long *)up));
 #else
-	if (sizeof (u_int) == 4) {
+	if (sizeof (u_int) < sizeof (u_long)) {
+		u_long l;
+
+		switch (xdrs->x_op) {
+		      case XDR_ENCODE:
+			l = (u_long) *up;
+			return XDR_PUTLONG(xdrs, &l);
+
+		      case XDR_DECODE:
+			if (!XDR_GETLONG(xdrs, &l)) {
+				return FALSE;
+			}
+			*up = (u_int) l;
+			return TRUE;
+		}
+	} else if (sizeof (u_int) == sizeof (u_long)) {
 		return (xdr_u_long(xdrs, (u_long *)up));
-	} else {
+	} else if (sizeof (u_int) == sizeof (u_short)) {
 		return (xdr_short(xdrs, (short *)up));
+	} else {
+		/* force unresolved reference (link-time error): */
+		extern unexpected_sizes_in_xdr_u_int ();
+
+		unexpected_sizes_in_xdr_u_int();
 	}
 #endif
 }
diff --git a/sunrpc/xdr_mem.c b/sunrpc/xdr_mem.c
index fb15f113ce..ac7c9541d0 100644
--- a/sunrpc/xdr_mem.c
+++ b/sunrpc/xdr_mem.c
@@ -99,7 +99,7 @@ xdrmem_getlong(xdrs, lp)
 
 	if ((xdrs->x_handy -= 4) < 0)
 		return (FALSE);
-	*lp = (long)ntohl((u_long)(*((int32_t *)(xdrs->x_private))));
+	*lp = (int32_t) ntohl((*((int32_t *)(xdrs->x_private))));
 	xdrs->x_private += 4;
 	return (TRUE);
 }
diff --git a/sunrpc/xdr_rec.c b/sunrpc/xdr_rec.c
index 45435951d0..974e8295dd 100644
--- a/sunrpc/xdr_rec.c
+++ b/sunrpc/xdr_rec.c
@@ -201,14 +201,14 @@ xdrrec_getlong(xdrs, lp)
 	if (rstrm->fbtbc >= BYTES_PER_XDR_UNIT &&
 	    rstrm->in_boundry - (char *) buflp >= BYTES_PER_XDR_UNIT)
 	{
-		*lp = ntohl(*buflp);
+		*lp = (int32_t) ntohl(*buflp);
 		rstrm->fbtbc -= BYTES_PER_XDR_UNIT;
 		rstrm->in_finger += BYTES_PER_XDR_UNIT;
 	} else {
 		if (! xdrrec_getbytes(xdrs, (caddr_t) &mylong,
 				      BYTES_PER_XDR_UNIT))
 			return FALSE;
-		*lp = ntohl(mylong);
+		*lp = (int32_t) ntohl(mylong);
 	}
 	return TRUE;
 }
diff --git a/sunrpc/xdr_stdio.c b/sunrpc/xdr_stdio.c
index da4877a9e8..5f016993e7 100644
--- a/sunrpc/xdr_stdio.c
+++ b/sunrpc/xdr_stdio.c
@@ -108,7 +108,7 @@ xdrstdio_getlong(xdrs, lp)
 
 	if (fread((caddr_t)&mycopy, 4, 1, (FILE *)xdrs->x_private) != 1)
 		return (FALSE);
-	*(int32_t*)lp = ntohl(mycopy);
+	*lp = (int32_t) ntohl(mycopy);
 	return (TRUE);
 }