Fixed overflow in chkrange(). Some out of bounds block numbers,

e.g. -1, were not detected.  Use a bulletproof check that doesn't
depend on special properties of the args or the limit.

PR:	3528
This commit is contained in:
Bruce Evans 1997-12-21 00:00:44 +00:00
parent 8578f44149
commit db398a8bd4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=31910
3 changed files with 3 additions and 3 deletions

View File

@ -235,7 +235,7 @@ chkrange(blk, cnt)
{
register int c;
if ((unsigned)(blk + cnt) > maxfsblock)
if (blk < 0 || blk >= maxfsblock || cnt < 0 || cnt > maxfsblock - blk)
return (1);
c = dtog(&sblock, blk);
if (blk < cgdmin(&sblock, c)) {

View File

@ -235,7 +235,7 @@ chkrange(blk, cnt)
{
register int c;
if ((unsigned)(blk + cnt) > maxfsblock)
if (blk < 0 || blk >= maxfsblock || cnt < 0 || cnt > maxfsblock - blk)
return (1);
c = dtog(&sblock, blk);
if (blk < cgdmin(&sblock, c)) {

View File

@ -235,7 +235,7 @@ chkrange(blk, cnt)
{
register int c;
if ((unsigned)(blk + cnt) > maxfsblock)
if (blk < 0 || blk >= maxfsblock || cnt < 0 || cnt > maxfsblock - blk)
return (1);
c = dtog(&sblock, blk);
if (blk < cgdmin(&sblock, c)) {