X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fmedia%2FJpegMetadataExtractorTest.php;h=c943cef906108ac8837abe7e9afebb0cdf6dd59f;hp=0991254119cbf761c8e73fe314fae3257848e5aa;hb=f17f841a9dfa1bee3f8ed47a09f06d1226452573;hpb=fb7b3eebeb8de47eb42e8d6ccf204106a2d6d9e4 diff --git a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php index 0991254119..c943cef906 100644 --- a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php +++ b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php @@ -108,4 +108,21 @@ class JpegMetadataExtractorTest extends MediaWikiTestCase { $expected = 'BE'; $this->assertEquals( $expected, $res['byteOrder'] ); } + + 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-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' ); + } }