|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73968 Premature failing of XBM reading
Submitted: 2017-01-21 00:02 UTC Modified: 2017-01-21 12:09 UTC
From: Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: 7.0Git-2017-01-20 (snap) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
New email:
PHP Version: OS:


 [2017-01-21 00:02 UTC]
libgd's XBM reader calculates the maximum number of image data
bytes to read in advance. However, it doesn't take into account
the line padding, so reading of XBM files with a width that is not
a multiple of 8 is likely to fail, for instance with the following

    #define test_width 10
    #define test_height 10
    static unsigned char test_bits[] = {
      0xFF, 0x03, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 
      0xFF, 0x03, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00};

Test script:

$im = imagecreatefromxbm(__DIR__ . '/test.xbm');

Expected result:
resource(%d) of type (gd)

Actual result:
Warning: imagecreatefromxbm(): EOF before image was complete in %s on line %d

Warning: imagecreatefromxbm(): '%s' is not a valid XBM file in %s on line %d


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-21 00:03 UTC]
-Assigned To: +Assigned To: cmb
 [2017-01-21 12:09 UTC]
This issue had been reported against GD with
 [2017-01-21 12:28 UTC]
Automatic comment on behalf of
Log: Fix #73968: Premature failing of XBM reading
 [2017-01-21 12:28 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 22 04:01:29 2024 UTC