Throw an exception if the data location is invalid. (#842)

v0.27.3
Kevin Backhouse 6 years ago committed by Luis Díaz Más
parent 8dc87a1214
commit 7798ae2557

@ -570,12 +570,11 @@ namespace Exiv2 {
DataLocId CiffComponent::dataLocation(uint16_t tag)
{
DataLocId di = invalidDataLocId;
switch (tag & 0xc000) {
case 0x0000: di = valueData; break;
case 0x4000: di = directoryData; break;
case 0x0000: return valueData;
case 0x4000: return directoryData;
default: throw Error(kerCorruptedMetadata);
}
return di;
} // CiffComponent::dataLocation
/*!

@ -74,7 +74,6 @@ namespace Exiv2 {
//! Type to identify where the data is stored in a directory
enum DataLocId {
invalidDataLocId,
valueData,
directoryData,
lastDataLocId

Binary file not shown.

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
from system_tests import CaseMeta, path, check_no_ASAN_UBSAN_errors
class InvalidDataLocationInCiffComponentDoRead(metaclass=CaseMeta):
"""
Regression test for the bug described in:
https://github.com/Exiv2/exiv2/issues/841
An invalid data location causes an assertion failure.
"""
url = "https://github.com/Exiv2/exiv2/issues/841"
filename = path("$data_path/issue_841_poc.crw")
commands = ["$exiv2 $filename"]
stdout = [""]
stderr = [
"""$exiv2_exception_message $filename:
$kerCorruptedMetadata
"""]
retval = [1]
Loading…
Cancel
Save