xdrmem_setpos): Don't compare addresses as signed longs, check for
authordrepper <drepper>
Wed, 18 Oct 2006 19:25:01 +0000 (19:25 +0000)
committerdrepper <drepper>
Wed, 18 Oct 2006 19:25:01 +0000 (19:25 +0000)
x_base + pos overflow.

sunrpc/xdr_mem.c

index e3167de..7b1261b 100644 (file)
@@ -177,13 +177,15 @@ xdrmem_setpos (xdrs, pos)
 {
   caddr_t newaddr = xdrs->x_base + pos;
   caddr_t lastaddr = xdrs->x_private + xdrs->x_handy;
+  size_t handy = lastaddr - newaddr;
 
-  if ((long) newaddr > (long) lastaddr
-      || (UINT_MAX < LONG_MAX
-         && (long) UINT_MAX < (long) lastaddr - (long) newaddr))
+  if (newaddr > lastaddr
+      || newaddr < xdrs->x_base
+      || handy != (u_int) handy)
     return FALSE;
+
   xdrs->x_private = newaddr;
-  xdrs->x_handy = (long) lastaddr - (long) newaddr;
+  xdrs->x_handy = (u_int) handy;
   return TRUE;
 }