Bug 364144 - invalid XBM leads to out of bounds read
Summary: invalid XBM leads to out of bounds read
Status: RESOLVED UPSTREAM
Alias: None
Product: okular
Classification: Applications
Component: Image backend components (show other bugs)
Version: 0.25.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-09 12:20 UTC by rtpublic1
Modified: 2016-06-17 06:16 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rtpublic1 2016-06-09 12:20:25 UTC
An xbm file with the wrong width and/or height information leads to out of bounds reads.
Example file:

#define example_width 12
#define example_height 10000
static unsigned char example_bits[] = {
   0x00, 0x00,
   0x00, 0x00
   0x00, 0x00
   0x40, 0x00,
   0xe0, 0x00,
   0xf0, 0x01,
   0xf8, 0x03,
   0xe0, 0x00,
   0xe0, 0x00,
   0xe0, 0x00,
   0xe0, 0x00,
   0xe0, 0x00,
   0xe0, 0x00,
   0x00, 0x00
   0x00, 0x00
   0x00, 0x00
};

The actual height of the image is 16, as can be seen in the pixel array (each row represents one row of pixels). Okular displays this image as 10000 pixels high, with rows > 16 filled with seemingly random data.

Version info from About box:
Okular
Version 0.25.0
Using KDE Development Platform 4.14.20

Backend info:
Image Backend
Version 0.1.2
Using KDE Development Platform 4.14.20


Reproducible: Always

Steps to Reproduce:
1. Save given XBM to example.xbm
2. Run okular example.xbm

Actual Results:  
Displayed image is 10000 pixels high, with all but the top 16 seemingly random.

Expected Results:  
Displayed image is 16 pixels high and/or a warning/error about an invalid image is shown.
Comment 1 Albert Astals Cid 2016-06-16 23:02:04 UTC
The code for reading xbm files we are using is part of Qt. So any program using Qt to read images will have this problem. Please report the bug upstream at https://bugreports.qt.io/
Comment 2 rtpublic1 2016-06-17 06:16:28 UTC
OK, I'll do that.