From: L10n-bot Date: Fri, 23 Feb 2018 21:09:54 +0000 (+0000) Subject: Merge "Localisation updates from https://translatewiki.net." X-Git-Tag: 1.31.0-rc.0~520 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=55765c051cf4d5e4b5e4319ac091447e7605fbab;hp=a4e1e2f0b170f1e15da42d9604ee4fc7cde3a73d;p=lhc%2Fweb%2Fwiklou.git Merge "Localisation updates from https://translatewiki.net." --- diff --git a/includes/media/JpegMetadataExtractor.php b/includes/media/JpegMetadataExtractor.php index 0bd01cd6c9..3c778f36c1 100644 --- a/includes/media/JpegMetadataExtractor.php +++ b/includes/media/JpegMetadataExtractor.php @@ -158,6 +158,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 ); } } diff --git a/tests/phpunit/data/media/jpeg-segment-loop1.jpg b/tests/phpunit/data/media/jpeg-segment-loop1.jpg new file mode 100644 index 0000000000..962f3fe0e7 Binary files /dev/null and b/tests/phpunit/data/media/jpeg-segment-loop1.jpg differ diff --git a/tests/phpunit/data/media/jpeg-segment-loop2.jpg b/tests/phpunit/data/media/jpeg-segment-loop2.jpg new file mode 100644 index 0000000000..e3a7505c00 Binary files /dev/null and b/tests/phpunit/data/media/jpeg-segment-loop2.jpg differ diff --git a/tests/phpunit/data/media/jpeg-xmp-loop.jpg b/tests/phpunit/data/media/jpeg-xmp-loop.jpg deleted file mode 100644 index 962f3fe0e7..0000000000 Binary files a/tests/phpunit/data/media/jpeg-xmp-loop.jpg and /dev/null differ diff --git a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php index 97921727f5..c943cef906 100644 --- a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php +++ b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php @@ -110,8 +110,19 @@ class JpegMetadataExtractorTest extends MediaWikiTestCase { } public function testInfiniteRead() { + // test file truncated right after a segment, which previously + // caused an infinite loop looking for the next segment byte. // Should get past infinite loop and throw in wfUnpack() $this->setExpectedException( 'MWException' ); - $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-xmp-loop.jpg' ); + $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-segment-loop1.jpg' ); + } + + public function testInfiniteRead2() { + // test file truncated after a segment's marker and size, which + // would cause a seek past end of file. Seek past end of file + // doesn't actually fail, but prevents further reading and was + // devolving into the previous case (testInfiniteRead). + $this->setExpectedException( 'MWException' ); + $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-segment-loop2.jpg' ); } }