You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Panic could be triggered when passing pdf::file::FileOptions::load with invalid input. Panic info is shown below:
thread 'main' panicked at /DATA2/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/pdf-0.9.0/src/primitive.rs:767:33:
byte index 2 is not a char boundary; it is inside 'ߧ' (bytes 1..3) of <ߧ0101213085485+01*01'* /GgaBcqf'A<40110612185925+01'01'
Full stack backtrace:
0: rust_begin_unwind
at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/std/src/panicking.rs:617:5
1: core::panicking::panic_fmt
at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/core/src/panicking.rs:67:14
2: core::str::slice_error_fail_rt
3: core::str::slice_error_fail
at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/core/src/str/mod.rs:87:9
4: core::str::traits::<impl core::slice::index::SliceIndex<str> for core::ops::range::Range<usize>>::index
at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/core/src/str/traits.rs:235:21
5: core::str::traits::<impl core::ops::index::Index<I> for str>::index
at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/core/src/str/traits.rs:61:9
6: <pdf::primitive::Date as pdf::object::Object>::from_primitive
at /DATA2/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/pdf-0.9.0/src/primitive.rs:767:33
7: <core::option::Option<T> as pdf::object::Object>::from_primitive
at /DATA2/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/pdf-0.9.0/src/object/mod.rs:656:24
8: <pdf::object::types::InfoDict as pdf::object::FromDict>::from_dict
at /DATA2/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/pdf-0.9.0/src/object/types.rs:1551:10
9: <pdf::object::types::InfoDict as pdf::object::Object>::from_primitive
at /DATA2/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/pdf-0.9.0/src/object/types.rs:1551:10
10: <core::option::Option<T> as pdf::object::Object>::from_primitive
at /DATA2/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/pdf-0.9.0/src/object/mod.rs:656:24
11: <pdf::file::Trailer as pdf::object::FromDict>::from_dict
at /DATA2/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/pdf-0.9.0/src/file.rs:626:10
12: <pdf::file::Trailer as pdf::object::Object>::from_primitive
at /DATA2/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/pdf-0.9.0/src/file.rs:626:10
13: pdf::file::File<B,OC,SC,L>::load_data
at /DATA2/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/pdf-0.9.0/src/file.rs:579:26
14: pdf::file::FileOptions<OC,SC,L>::load
at /DATA2/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/pdf-0.9.0/src/file.rs:562:9
15: pdf_poc::main
at ./src/main.rs:4:21
16: core::ops::function::FnOnce::call_once
at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/core/src/ops/function.rs:250:5
Expected behavior
Not panic. It could be an error reported to the users.
Test environment:
Version: pdf = "0.9.0"
OS: Ubuntu 20.04, 64 bit
Target triple: x86_64-unknown-linux-gnu
Rustc version: rustc 1.73.0-nightly (076887268 2023-08-17)
To Reproduce
It can be reproduced with the following program:
fn main() {
let p = "crash.pdf";
if let Ok(data) = std::fs::read(p) {
if let Ok(file) = pdf::file::FileOptions::cached().load(data.as_slice()) {
for idx in 0..file.num_pages() {
let _ = file.get_page(idx);
}
}
}
}
Describe the bug
Panic could be triggered when passing
pdf::file::FileOptions::load
with invalid input. Panic info is shown below:thread 'main' panicked at /DATA2/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/pdf-0.9.0/src/primitive.rs:767:33:
byte index 2 is not a char boundary; it is inside 'ߧ' (bytes 1..3) of
<ߧ0101213085485+01*01'* /GgaBcqf'A<40110612185925+01'01'
Full stack backtrace:
Expected behavior
Not panic. It could be an error reported to the users.
Test environment:
Version:
pdf = "0.9.0"
OS: Ubuntu 20.04, 64 bit
Target triple: x86_64-unknown-linux-gnu
Rustc version: rustc 1.73.0-nightly (076887268 2023-08-17)
To Reproduce
It can be reproduced with the following program:
crash.pdf is attached:
crash.pdf.zip
The text was updated successfully, but these errors were encountered: