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:
parent
8578f44149
commit
db398a8bd4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=31910
@ -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)) {
|
||||
|
@ -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)) {
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user