X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmedia%2FJpegMetadataExtractor.php;h=8a26f606f978c292ece3d2b4789cfac3b7920355;hb=0fd6cab93875296beac0c1c30203ec569ef21747;hp=229a891db83c3518af33c0f6dcaf26717eb6c53a;hpb=bed43f525501ddf80995daa8e406414500ce3d1d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/JpegMetadataExtractor.php b/includes/media/JpegMetadataExtractor.php index 229a891db8..8a26f606f9 100644 --- a/includes/media/JpegMetadataExtractor.php +++ b/includes/media/JpegMetadataExtractor.php @@ -21,6 +21,8 @@ * @ingroup Media */ +use Wikimedia\XMPReader\Reader as XMPReader; + /** * Class for reading jpegs and extracting metadata. * see also BitmapMetadataHandler. @@ -82,7 +84,7 @@ class JpegMetadataExtractor { // this is just a sanity check throw new MWException( 'Too many jpeg segments. Aborting' ); } - while ( $buffer !== "\xFF" ) { + while ( $buffer !== "\xFF" && !feof( $fh ) ) { // In theory JPEG files are not allowed to contain anything between the sections, // but in practice they sometimes do. It's customary to ignore the garbage data. $buffer = fread( $fh, 1 ); @@ -158,6 +160,8 @@ class JpegMetadataExtractor { if ( $size['int'] < 2 ) { throw new MWException( "invalid marker size in jpeg" ); } + // Note it's possible to seek beyond end of file if truncated. + // fseek doesn't report a failure in this case. fseek( $fh, $size['int'] - 2, SEEK_CUR ); } }