View Issue Details

IDProjectCategoryView StatusLast Update
0009223libextractorpluginspublic2024-09-24 21:17
Reporterpinotree Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
Status newResolutionopen 
Product Version1.13 
Summary0009223: exiv2_extractor.cc raises uncatchable exception in its BasicIo implementation with Exiv 0.28
DescriptionThe exiv2 extractor implements its own Exiv2::BasicIo to feed the data to the Exiv2 library. The implementation for the path() method always throws an exception, which is now a problem when using Exiv2 0.28 and greater:
- path() is declared in Exiv2 as noexcept, which means it must not throw an exception
- path() may be actually called in error paths to compose an error string (which is also a reason for it to be noexcept)
Because of that, when the plugin is used to scan a file that does not contain Exiv metadata (e.g. a text file), then the plugin crashes.

Attached there is a patch to add a new class method in the custom BasicIo to always return "(unknown)" in path(). From what I can see, this seems to be the only possible implementation.
Steps To ReproduceBuild libextractor 1.13 using Exiv2 0.28, then run:
$ extract -V -V src/plugins/testdata/README
Keywords for file src/plugins/testdata/README:
terminate called after throwing an instance of 'Exiv2::Error'
  what(): Failed to decode Lang Alt qualifier %1 with opt=%2
mimetype - text/plain
TagsNo tags attached.
Attached Files
exiv2-path.diff (1,118 bytes)   
--- a/src/plugins/exiv2_extractor.cc
+++ b/src/plugins/exiv2_extractor.cc
@@ -48,6 +48,14 @@ private:
  */
 struct EXTRACTOR_ExtractContext *ec;
 
+/**
+ * Dummy string "(unknown)" to represent the unknown source.
+ *
+ * It is needed as class variable as in EXIV2 0.28 and greater the path() method
+ * returns a const reference.
+ */
+std::string io_path;
+
 public:
 
 /**
@@ -58,6 +66,7 @@ public:
 ExtractorIO (struct EXTRACTOR_ExtractContext *s_ec)
 {
   ec = s_ec;
+  io_path = "(unknown)";
 }
 
 
@@ -589,9 +598,9 @@ ExtractorIO::eof () const
 
 
 /**
- * Not supported.
+ * Return the string with the path.
  *
- * @throws error
+ * @return the string "(unknown)"
  */
 #if EXIV2_TEST_VERSION (0,28,0)
 const std::string&
@@ -601,13 +610,7 @@ std::string
 ExtractorIO::path () const
 #endif
 {
-#if EXIV2_TEST_VERSION (0,28,0)
-  throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed);
-#elif EXIV2_TEST_VERSION (0,27,0)
-  throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
-#else
-  throw Exiv2::BasicError<char> (42 /* error code */);
-#endif
+  return io_path;
 }
 
 
exiv2-path.diff (1,118 bytes)   

Activities

Issue History

Date Modified Username Field Change
2024-09-24 21:17 pinotree New Issue
2024-09-24 21:17 pinotree File Added: exiv2-path.diff