php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73019 getimageszie can not recognize a special kind of jpg file
Submitted: 2016-09-05 09:45 UTC Modified: 2016-09-06 09:26 UTC
From: zws at ahtvu dot ah dot cn Assigned: cmb (profile)
Status: Duplicate Package: GetImageSize related
PHP Version: 7.0.10 OS: any
Private report: No CVE-ID: None
 [2016-09-05 09:45 UTC] zws at ahtvu dot ah dot cn
Description:
------------
   I found a problem when php recongize a jpg file.This file can be rendered by acdsee,ie,firefox,etc,but getimagesize function returns false.
   Your can download the file from url http://bm.ahtvu.ah.cn/img/20163/a/6/5177/org_faceimg.jpg.
   This file have a lot of zeros between jpg data sections,I check php source code and find that php_next_marker function can not cope with it.
   I give the following patch which I can not ensure ok under any circumstances.

[root@cache84 standard]# diff image.c patch_image.c 
416c416
<       } while (marker == 0xff);
---
>       } while (marker == 0xff || marker == 0);


Test script:
---------------
<?php 

var_dump(getimagesize('/root/f.jpg'));


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-05 10:50 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2016-09-05 10:50 UTC] cmb@php.net
That appears to be a duplicate of bug #72278, which has been
fixed, but the fix has not yet been released.

Can you please confirm with a current Git snapshot of PHP?
 [2016-09-06 01:31 UTC] zws at ahtvu dot ah dot cn
-Status: Feedback +Status: Closed
 [2016-09-06 01:31 UTC] zws at ahtvu dot ah dot cn
Hello,I chekout last version of php,and test the relate code,the result is ok,thanks.

[root@node5 bin]# ./php -v
PHP 7.2.0-dev (cli) (built: Sep  6 2016 09:18:22) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
[root@node5 bin]# ./php  ~/zws.php 

Warning: getimagesize(): corrupt JPEG data: 888 extraneous bytes before marker in /root/zws.php on line 3
array(7) {
  [0]=>
  int(120)
  [1]=>
  int(160)
  [2]=>
  int(2)
  [3]=>
  string(24) "width="120" height="160""
  ["bits"]=>
  int(8)
  ["channels"]=>
  int(3)
  ["mime"]=>
  string(10) "image/jpeg"
}
 [2016-09-06 09:26 UTC] cmb@php.net
-Status: Closed +Status: Duplicate
 [2016-09-06 09:26 UTC] cmb@php.net
Thanks for the quick confirmation!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC