Repeated iptcembed() adds superfluous FF bytes
| Bug #70096 | Repeated iptcembed() adds superfluous FF bytes | ||||
|---|---|---|---|---|---|
| Submitted: | 2015-07-18 19:06 UTC | Modified: | 2015-07-18 19:42 UTC | ||
| From: | cmb@php.net | Assigned: | cmb (profile) | ||
| Status: | Closed | Package: | GetImageSize related | ||
| PHP Version: | 7.0.0beta1 | OS: | * | ||
| Private report: | No | CVE-ID: | None | ||
[2015-07-18 19:06 UTC] cmb@php.net
Description:
------------
Repeately calling iptcembed() causes a superfluous FF byte to be
added with each call. While this may not be a violation of the
JFIF standard (the specs are not publicly available, apparently),
I'd nonetheless consider this a bug, because repeated embedding of
the same metadata should not result in different files.
Test script:
---------------
<?php
$filename = __DIR__ . '/test.jpg';
@unlink($filename);
$im = imagecreatetruecolor(10, 10);
imagejpeg($im, $filename);
imagedestroy($im);
$data = "\x1C\x02x\x00\x0ATest image"
. "\x1C\x02t\x00\x22Copyright 2008-2009, The PHP Group";
$content = iptcembed($data, $filename);
$fp = fopen($filename, "wb");
fwrite($fp, $content);
fclose($fp);
echo filesize($filename), PHP_EOL;
clearstatcache();
$content = iptcembed($data, $filename);
$fp = fopen($filename, "wb");
fwrite($fp, $content);
fclose($fp);
echo filesize($filename), PHP_EOL;
?>
Expected result:
----------------
779
779
Actual result:
--------------
779
780
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2015-07-18 19:06 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
[2015-07-18 19:42 UTC] cmb@php.net
-Status: Assigned +Status: Analyzed
[2015-07-18 19:42 UTC] cmb@php.net
[2015-07-18 20:58 UTC] cmb@php.net
-Status: Analyzed +Status: Closed