TechnikTobi / little_exif

A little library for reading and writing EXIF data in pure Rust.
Apache License 2.0
22 stars 5 forks source link

Panic with file that exiftool parse(with one warning) #3

Closed qarmin closed 1 month ago

qarmin commented 9 months ago

Code that cause panic

match little_exif::metadata::Metadata::new_from_path(&file_entry.path) {
  Ok(mt) => {
      for tag in mt.data() {
          dbg!(tag);
      }
  }
  Err(e) => {
      println!("Error: {:?}", e);
  }
}

Backtrace

        // Assert that we have enough data to unpack
        assert!(2 + IFD_ENTRY_LENGTH as usize * number_of_entries as usize + IFD_END.len() <= encoded_data.len());
stack backtrace:
Could not get IFD0 tags!
WARNING: Can't read metadata from file - Create new & empty struct
(1152, 2048), file-name /home/rafal/Downloads/Untitled Folder/301581901-1c6fca25-e53f-4275-93f4-098d6b853dae.jpg
   0: rust_begin_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:127:5
   3: little_exif::metadata::Metadata::decode_ifd
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/little_exif-0.3.0/src/metadata.rs:401:3
   4: little_exif::metadata::Metadata::decode_ifd
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/little_exif-0.3.0/src/metadata.rs:461:33
   5: little_exif::metadata::Metadata::decode_metadata_general
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/little_exif-0.3.0/src/metadata.rs:369:37
   6: little_exif::metadata::Metadata::new_from_path
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/little_exif-0.3.0/src/metadata.rs:104:26
   7: czkawka_core::similar_images::SimilarImages::collect_image_file_entry
             at ./czkawka_core/src/similar_images.rs:420:15
   8: czkawka_core::similar_images::SimilarImages::hash_images::{{closure}}::{{closure}}
             at ./czkawka_core/src/similar_images.rs:289:17

problematic file

301581895-a7b4390a-e9f4-46cc-b04f-eb1ba677204c.jpg.zip

exiftool only warning - properly parse entire file

[minor] Skipped unknown 7 bytes after JPEG APP1 segment
TechnikTobi commented 9 months ago

Will look into that.

TechnikTobi commented 1 month ago

Closing this issue. Reason: The given JPG file is corrupted; The application segment APP1 is shorter than described (given length: 0xCAE bytes; actual length: 0xCA3 bytes).