bug 255067 reduce max image size to prevent DOS

git-svn-id: svn://10.0.0.236/branches/AVIARY_1_0_20040515_BRANCH@161378 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dveditz%cruzio.com
2004-08-27 10:34:14 +00:00
parent 7d31e7d0f7
commit 24aa0012c2
3 changed files with 14 additions and 1 deletions

View File

@@ -72,6 +72,13 @@ NS_IMETHODIMP gfxImageFrame::Init(nscoord aX, nscoord aY, nscoord aWidth, nscoor
return NS_ERROR_FAILURE;
}
/* reject over-wide or over-tall images */
const PRInt32 k64KLimit = 0x0000FFFF;
if ( aWidth > k64KLimit || aHeight > k64KLimit ){
NS_ERROR("image too big");
return NS_ERROR_FAILURE;
}
nsresult rv;
mOffset.MoveTo(aX, aY);

View File

@@ -131,6 +131,10 @@ nsresult nsImageWin :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMa
return NS_ERROR_UNEXPECTED;
}
// limit images to 64k pixels on a side (~55 feet on a 100dpi monitor)
const PRInt32 k64KLimit = 0x0000FFFF;
if (aWidth > k64KLimit || aHeight > k64KLimit)
return NS_ERROR_FAILURE;
if (mNumPaletteColors >= 0){
// If we have a palette

View File

@@ -274,7 +274,9 @@ NS_METHOD nsBMPDecoder::ProcessData(const char* aBuffer, PRUint32 aCount)
CalcBitShift();
}
// BMPs with negative width are invalid
if (mBIH.width < 0)
// Reject extremely wide images to keep the math sane
const PRInt32 k64KWidth = 0x0000FFFF;
if (mBIH.width < 0 || mBIH.width > k64KWidth)
return NS_ERROR_FAILURE;
PRUint32 real_height = (mBIH.height > 0) ? mBIH.height : -mBIH.height;