Patch to fix bounds checking/overflow.

Obtained from:	OpenBSD
This commit is contained in:
Darren Reed 2002-07-31 12:50:28 +00:00
parent eeebf53e24
commit 7fc37b7c09
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=101045

View File

@ -78,11 +78,12 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
u_int nodesize;
/* like strings, arrays are really counted arrays */
if (! xdr_u_int(xdrs, sizep)) {
if (!xdr_u_int(xdrs, sizep)) {
return (FALSE);
}
c = *sizep;
if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) {
if ((c > maxsize && UINT_MAX/elsize < c) &&
(xdrs->x_op != XDR_FREE)) {
return (FALSE);
}
nodesize = c * elsize;
@ -152,7 +153,7 @@ xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem)
elptr = basep;
for (i = 0; i < nelem; i++) {
if (! (*xdr_elem)(xdrs, elptr)) {
if (!(*xdr_elem)(xdrs, elptr)) {
return(FALSE);
}
elptr += elemsize;