BMP with DIB HeaderSize != 40 could not be used anymore

Bug #2056569 reported by Tobias Janßen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
freeimage (Ubuntu)
New
Undecided
Unassigned

Bug Description

1) Ubuntu 22.04.3 LTS
2) libfreeimage3 3.18.0+ds2-6ubuntu5.1
3) Should open BMP files with all supported dib headersizes
4) When using BMP files with DIB Header sizes != sizeof(BITMAPINFOHEADER) loading results in "invalid Format"

Since 3.18.0+ds2-6ubuntu5.1 "CheckBitmapInfoHeader" was introduced into PuginBMP.

The CheckBitmapInfoHeader performs (shortened)

if (bih->biSize != sizeof(BITMAPINFOHEADER)) {
   return FALSE

BMP DIB Header sizes could be 40, 52, 56, 108, 124 bytes. BITMAPINFOHEADER is always size 40.
Resulting bmp files with different dib header sizes could not be loaded anymore

See the one attached.

A fix could be:

CheckBitmapInfoHeader(BITMAPINFOHEADER *bih) {
  if (bih->biSize != sizeof(BITMAPINFOHEADER)) {

    switch(bih->biSize) {
 case 40: // sizeof(BITMAPINFOHEADER)
 case 52: // sizeof(BITMAPV2INFOHEADER)
 case 56: // sizeof(BITMAPV3INFOHEADER)
 case 108: // sizeof(BITMAPV4HEADER)
 case 124: // sizeof(BITMAPV5HEADER)
  return TRUE;
 default:
  return FALSE;
    }
 }

Revision history for this message
Tobias Janßen (tobiasjanssen) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.