diff --git a/src/rx/xdr.c b/src/rx/xdr.c index 8ca8a4aec7..c1d07c0945 100644 --- a/src/rx/xdr.c +++ b/src/rx/xdr.c @@ -558,6 +558,8 @@ xdr_string(xdrs, cpp, maxsize) u_int size; u_int nodesize; + if (maxsize > ((~0) >> 1) - 1) maxsize = ((~0) >> 1) - 1; + /* * first deal with the length since xdr strings are counted-strings */ diff --git a/src/rx/xdr_array.c b/src/rx/xdr_array.c index ea5de24f5f..d49561095b 100644 --- a/src/rx/xdr_array.c +++ b/src/rx/xdr_array.c @@ -84,7 +84,10 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) register caddr_t target = *addrp; register u_int c; /* the actual element count */ register bool_t stat = TRUE; - register int nodesize; + register u_int nodesize; + + i = ((~0) >> 1) / elsize; + if (maxsize > i) maxsize = i; /* like strings, arrays are really counted arrays */ if (! xdr_u_int(xdrs, sizep)) { diff --git a/src/rx/xdr_arrayn.c b/src/rx/xdr_arrayn.c index e89322aa86..70cb23f2f3 100644 --- a/src/rx/xdr_arrayn.c +++ b/src/rx/xdr_arrayn.c @@ -89,7 +89,10 @@ bool_t xdr_arrayN(xdrs, addrp, sizep, maxsize, elsize, elproc) register caddr_t target = *addrp; register u_int c; /* the actual element count */ register bool_t stat = TRUE; - register int nodesize; + register u_int nodesize; + + i = ((~0) >> 1) / elsize; + if (maxsize > i) maxsize = i; /* like strings, arrays are really counted arrays */ if (! xdr_u_int(xdrs, sizep)) {