Changed to ignore dubious values in the fileSize and imagesize fields. These fields are not needed in the actual decoding of BMP images anyway. Some Windows image viewers are equally forgiving with these fields, as there are programs that write dubious BMPs.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6091 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matthew Wilber 2004-01-15 02:03:48 +00:00
parent 74f9d75678
commit 023968853e

View File

@ -557,26 +557,8 @@ identify_bmp_header(BPositionIO *inSource, translator_info *outInfo,
return B_NO_TRANSLATOR;
if (!msheader.imagesize && msheader.compression)
return B_NO_TRANSLATOR;
if (msheader.imagesize && fileHeader.fileSize <
fileHeader.dataOffset + msheader.imagesize)
return B_NO_TRANSLATOR;
if (msheader.colorsimportant > msheader.colorsused)
return B_NO_TRANSLATOR;
// If file is uncompressed, calculate the size of the
// actual image data and use that to determine if
// fileHeader.fileSize, fileHeader.dataOffset
// and msheader.imagesize are reasonable values
if (msheader.compression == BMP_NO_COMPRESS) {
uint32 imagesize = get_rowbytes(msheader.width,
msheader.bitsperpixel) * msheader.height;
if (msheader.imagesize && msheader.imagesize <
imagesize)
return B_NO_TRANSLATOR;
if (fileHeader.fileSize < fileHeader.dataOffset +
imagesize)
return B_NO_TRANSLATOR;
}
return B_NO_TRANSLATOR;
if (outInfo) {
outInfo->type = B_BMP_FORMAT;
@ -644,15 +626,6 @@ identify_bmp_header(BPositionIO *inSource, translator_info *outInfo,
os2header.bitsperpixel != 8 &&
os2header.bitsperpixel != 24)
return B_NO_TRANSLATOR;
// Calculate the size of the actual image data
// and use that to determine if
// fileHeader.fileSize and fileHeader.dataOffset
// are reasonable values
uint32 imagesize = get_rowbytes(os2header.width,
os2header.bitsperpixel) * os2header.height;
if (fileHeader.fileSize < fileHeader.dataOffset + imagesize)
return B_NO_TRANSLATOR;
if (outInfo) {
outInfo->type = B_BMP_FORMAT;