CVE-2019-17402.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp
  2. index 29311fd..c0d9553 100644
  3. --- a/src/crwimage_int.cpp
  4. +++ b/src/crwimage_int.cpp
  5. @@ -268,6 +268,9 @@ namespace Exiv2 {
  6. #ifdef EXIV2_DEBUG_MESSAGES
  7. std::cout << "Reading directory 0x" << std::hex << tag() << "\n";
  8. #endif
  9. + if (this->offset() + this->size() > size)
  10. + throw Error(kerOffsetOutOfRange);
  11. +
  12. readDirectory(pData + offset(), this->size(), byteOrder);
  13. #ifdef EXIV2_DEBUG_MESSAGES
  14. std::cout << "<---- 0x" << std::hex << tag() << "\n";
  15. diff --git a/test/data/POC-file_issue_1019 b/test/data/POC-file_issue_1019
  16. new file mode 100755
  17. index 0000000..e69de29
  18. diff --git a/tests/bugfixes/github/test_issue_1019.py b/tests/bugfixes/github/test_issue_1019.py
  19. new file mode 100644
  20. index 0000000..c2682f9
  21. --- /dev/null
  22. +++ b/tests/bugfixes/github/test_issue_1019.py
  23. @@ -0,0 +1,14 @@
  24. +from system_tests import CaseMeta, path
  25. +
  26. +
  27. +class OverreadInCiffDirectoryReadDirectory(metaclass=CaseMeta):
  28. +
  29. + filename = path("$data_path/POC-file_issue_1019")
  30. + commands = ["$exiv2 -pv $filename"]
  31. + stdout = [""]
  32. + stderr = [
  33. + """$exiv2_exception_message $filename:
  34. +$kerOffsetOutOfRange
  35. +"""
  36. + ]
  37. + retval = [1]
  38. diff --git a/tests/suite.conf b/tests/suite.conf
  39. index 5b31930..dab7427 100644
  40. --- a/tests/suite.conf
  41. +++ b/tests/suite.conf
  42. @@ -19,6 +19,7 @@ largeiptc_test: ${ENV:exiv2_path}/largeiptc-test${ENV:binary_extension}
  43. easyaccess_test: ${ENV:exiv2_path}/easyaccess-test${ENV:binary_extension}
  44. [variables]
  45. +kerOffsetOutOfRange: Offset out of range
  46. kerFailedToReadImageData: Failed to read image data
  47. kerCorruptedMetadata: corrupted image metadata
  48. kerInvalidMalloc: invalid memory allocation request