r99477 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99476‎ | r99477 | r99478 >
Date:14:05, 11 October 2011
Author:bawolff
Status:ok (Comments)
Tags:
Comment:
(bug 31588, sort of) Jpeg metadata code wasn't handling padding bytes properly.

Per the spec, segments can have arbitrary runs of 0xFF's between segments that should be skipped.
Modified paths:
  • /trunk/phase3/includes/media/JpegMetadataExtractor.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/media/JpegMetadataExtractor.php
@@ -58,7 +58,7 @@
5959 throw new MWException( 'Too many jpeg segments. Aborting' );
6060 }
6161 if ( $buffer !== "\xFF" ) {
62 - throw new MWException( "Error reading jpeg file marker" );
 62+ throw new MWException( "Error reading jpeg file marker. Expected 0xFF but got " . bin2hex( $buffer ) );
6363 }
6464
6565 $buffer = fread( $fh, 1 );
@@ -123,6 +123,9 @@
124124 } elseif ( $buffer === "\xD9" || $buffer === "\xDA" ) {
125125 // EOI - end of image or SOS - start of scan. either way we're past any interesting segments
126126 return $segments;
 127+ } elseif ( $buffer === "\xFF" ) {
 128+ // Padding byte. Skip.
 129+ continue;
127130 } else {
128131 // segment we don't care about, so skip
129132 $size = unpack( "nint", fread( $fh, 2 ) );

Follow-up revisions

RevisionCommit summaryAuthorDate
r100575(follow up r99477) not sure what I was doing on r99477, but its not right (do...bawolff02:41, 24 October 2011
r100576(follow-up r100575 / r99477) unit-tests for jpegMetadataExtractor dealing wit...bawolff02:47, 24 October 2011
r102516REL1_18 MFT r99092, r99477reedy14:44, 9 November 2011
r1025881.18wmf1 MFT r92846, r98764, r99477reedy22:51, 9 November 2011

Comments

#Comment by Nikerabbit (talk | contribs)   14:11, 11 October 2011

Is there a test case for this?

#Comment by Bawolff (talk | contribs)   14:16, 11 October 2011

I could make one. There's a few images on commons currently showing the bug - File:Costesti_Cetatuie_Dacian_Fortress_2011_-_Stairs_and_Drain.jpg

Status & tagging log