In Jp2Image::readMetadata() in jp2image.cpp in Exiv2 0.27.2, an input file can result in an infinite loop and hang, with high CPU consumption. Remote attackers could leverage this vulnerability to cause a denial of service via a crafted file.
cpe:2.3:a:exiv2:exiv2:0.27.2:*:*:*:*:*:*:*
7E9A8822-0F6F-4561-81B3-38235F52116E
OR
cpe:2.3:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*
F7016A2A-8365-4F1A-89A2-7A19F2BCAE5B
cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*
23A7C53F-B80F-4E6A-AFA9-58EEA84BE11D
cpe:2.3:o:canonical:ubuntu_linux:19.10:*:*:*:*:*:*:*
A31C8344-3E02-4EB8-8BD8-4C84B7959624
OR
cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*
DEECE5FC-CACF-4496-A3E7-164736409252
cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:*
07B237A9-69A3-4A9C-9DA0-4E06BD37AE73
OR
**Describe the bug**
An input file can result in an infinite loop and hang, with high CPU consumption. Remote attackers could leverage this vulnerability to cause a denial of service via a crafted file.

**To Reproduce**
Steps to reproduce the behaviour:
excute 'build/bin/exiv2 Jp2Image_readMetadata_loop.poc'

**Expected behavior**
An infinite loop and hang, with high CPU consumption
![image](https://user-images.githubusercontent.com/17027039/65876735-8d91a500-e3bc-11e9-8f5b-b3cf28823956.png)


**Additional context**
The poc is here
[Jp2Image_readMetadata_loop.poc.zip](https://github.com/Exiv2/exiv2/files/3670911/Jp2Image_readMetadata_loop.poc.zip)


The code:

> io_->seek(restore,BasicIo::beg);
> io_->seek(subBox.length, Exiv2::BasicIo::cur);

leads to an infinite loop.


An infinite loop and hang in Exiv2::Jp2Image::readMetadata()
This is a GitHub Issue
repo:exiv2
owner:Exiv2
Title : An infinite loop and hang in Exiv2::Jp2Image::readMetadata()
Issue date:

--- start body ---
**Describe the bug**
An input file can result in an infinite loop and hang, with high CPU consumption. Remote attackers could leverage this vulnerability to cause a denial of service via a crafted file.

**To Reproduce**
Steps to reproduce the behaviour:
excute 'build/bin/exiv2 Jp2Image_readMetadata_loop.poc'

**Expected behavior**
An infinite loop and hang, with high CPU consumption
![image](https://user-images.githubusercontent.com/17027039/65876735-8d91a500-e3bc-11e9-8f5b-b3cf28823956.png)


**Additional context**
The poc is here
[Jp2Image_readMetadata_loop.poc.zip](https://github.com/Exiv2/exiv2/files/3670911/Jp2Image_readMetadata_loop.poc.zip)


The code:

> io_->seek(restore,BasicIo::beg);
> io_->seek(subBox.length, Exiv2::BasicIo::cur);

leads to an infinite loop.


--- end body ---

comments :
--- start comments ---

--- end comments ---