Enet4 / dicom-rs

Rust implementation of the DICOM standard
https://dicom-rs.github.io
Apache License 2.0
423 stars 82 forks source link

Panic when opening file via `dicom_object::file::open_file` #543

Closed qarmin closed 3 months ago

qarmin commented 3 months ago

File - compressed.zip

thread 'main' panicked at /home/runner/.cargo/git/checkouts/dicom-rs-165e2a1669724caa/239cba5/parser/src/stateful/decode.rs:729:45:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d9284afea99e0969a0e692b9e9fd61ea4ba21366/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/d9284afea99e0969a0e692b9e9fd61ea4ba21366/library/core/src/panicking.rs:74:14
   2: core::panicking::panic_bounds_check
             at /rustc/d9284afea99e0969a0e692b9e9fd61ea4ba21366/library/core/src/panicking.rs:276:5
   3: <usize as core::slice::index::SliceIndex<[T]>>::index
             at /rustc/d9284afea99e0969a0e692b9e9fd61ea4ba21366/library/core/src/slice/index.rs:301:10
   4: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/d9284afea99e0969a0e692b9e9fd61ea4ba21366/library/core/src/slice/index.rs:17:9
   5: <smallvec::SmallVec<A> as core::ops::index::Index<I>>::index
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/smallvec-1.13.2/src/lib.rs:2031:18
   6: dicom_parser::stateful::decode::StatefulDecoder<D,S,BD,TC>::read_value_us
             at /home/runner/.cargo/git/checkouts/dicom-rs-165e2a1669724caa/239cba5/parser/src/stateful/decode.rs:729:45
   7: <dicom_parser::stateful::decode::StatefulDecoder<D,S,BD> as dicom_parser::stateful::decode::StatefulDecode>::read_value_preserved
             at /home/runner/.cargo/git/checkouts/dicom-rs-165e2a1669724caa/239cba5/parser/src/stateful/decode.rs:989:32
   8: dicom_parser::dataset::read::DataSetReader<S>::read_value
             at /home/runner/.cargo/git/checkouts/dicom-rs-165e2a1669724caa/239cba5/parser/src/dataset/read.rs:568:45
   9: <dicom_parser::dataset::read::DataSetReader<S> as core::iter::traits::iterator::Iterator>::next
             at /home/runner/.cargo/git/checkouts/dicom-rs-165e2a1669724caa/239cba5/parser/src/dataset/read.rs:393:35
  10: dicom_object::mem::InMemDicomObject<D>::build_object
             at /home/runner/.cargo/git/checkouts/dicom-rs-165e2a1669724caa/239cba5/object/src/mem.rs:1845:38
  11: dicom_object::mem::<impl dicom_object::FileDicomObject<dicom_object::mem::InMemDicomObject<D>>>::open_file_with_all_options
             at /home/runner/.cargo/git/checkouts/dicom-rs-165e2a1669724caa/239cba5/object/src/mem.rs:376:22
  12: dicom_object::file::OpenFileOptions<D,T>::open_file
             at /home/runner/.cargo/git/checkouts/dicom-rs-165e2a1669724caa/239cba5/object/src/file.rs:130:9
  13: dicom_object::file::open_file
             at /home/runner/.cargo/git/checkouts/dicom-rs-165e2a1669724caa/239cba5/object/src/file.rs:31:28
  14: dicom::check_file
             at ./src/crates/dicom/src/main.rs:26:15
  15: dicom::main
             at ./src/crates/dicom/src/main.rs:21:9
  16: core::ops::function::FnOnce::call_once
             at /rustc/d9284afea99e0969a0e692b9e9fd61ea4ba21366/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
timeout: the monitored command dumped core

##### Automatic Fuzzer note, output status "None", output signal "Some(6)"
Enet4 commented 3 months ago

Thank you for reporting.

I assume that the problem is in the panic? Oddly enough, this might be a recent regression, as I could only reproduce it after using the upstream version of dicom-dump.