mdsteele / rust-cfb

Rust library for reading/writing Compound File Binary (structured storage) files
MIT License
46 stars 20 forks source link

assertion failed: sector_id < self.num_sectors at src/internal/sector.rs:65:9 #3

Closed messense closed 3 years ago

messense commented 3 years ago
---- doc::get_from_path stdout ----
thread 'doc::get_from_path' panicked at 'assertion failed: sector_id < self.num_sectors', /Users/messense/.cargo/registry/src/github.com-1ecc6299db9ec823/cfb-0.4.0/src/internal/sector.rs:65:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:50:5
   3: cfb::internal::sector::Sectors<F>::seek_within_sector
             at /Users/messense/.cargo/registry/src/github.com-1ecc6299db9ec823/cfb-0.4.0/src/internal/sector.rs:65:9
   4: cfb::internal::sector::Sectors<F>::seek_to_sector
             at /Users/messense/.cargo/registry/src/github.com-1ecc6299db9ec823/cfb-0.4.0/src/internal/sector.rs:57:9
   5: cfb::CompoundFile<F>::open
             at /Users/messense/.cargo/registry/src/github.com-1ecc6299db9ec823/cfb-0.4.0/src/lib.rs:640:30
   6: infer::matchers::doc::ole2
             at ./src/matchers/doc.rs:103:23
   7: infer::matchers::doc::is_doc
             at ./src/matchers/doc.rs:16:5
   8: infer::Type::matches
             at ./src/lib.rs:148:9
   9: infer::Infer::get::{{closure}}
             at ./src/lib.rs:219:42
  10: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::find
             at /Users/messense/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/slice/iter/macros.rs:251:24
  11: <core::iter::adapters::chain::Chain<A,B> as core::iter::traits::iterator::Iterator>::find
             at /Users/messense/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/adapters/chain.rs:173:21
  12: infer::Infer::get
             at ./src/lib.rs:219:9
  13: infer::Infer::get_from_path
             at ./src/lib.rs:238:12
  14: infer::get_from_path
             at ./src/lib.rs:452:5
  15: doc::doc::get_from_path
             at ./tests/common.rs:16:28
  16: doc::doc::get_from_path::{{closure}}
             at ./tests/common.rs:13:13
  17: core::ops::function::FnOnce::call_once
             at /Users/messense/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
  18: core::ops::function::FnOnce::call_once
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

sample.xls

use std::fs;
use std::io::Cursor;

let buf = fs::read("sample.xls").unwrap();
let file = cfb::CompoundFile::open(Cursor::new(buf)).unwrap();
messense commented 3 years ago

Never mind, it seems not an issue of rust-cfb. It's caused by incomplete input: https://github.com/bojand/infer/blob/3221954081587a8dbaee83f0b98a1bee49c54193/src/lib.rs#L236