Commit graph

375 commits

Author SHA1 Message Date
Chris Hennick
475b55df1d
Perform an extra sanity check on ZIP64 detection 2023-05-04 20:29:26 -07:00
Chris Hennick
cde5d5ed11
Implement shallow copy from within the file being written 2023-04-23 14:33:10 -07:00
Marli Frost
c4c6ec9e7c fix: clippy 2023-02-01 18:03:03 +00:00
Marli Frost
d06d4b295f refactor: move the new ZipStreamReader API to the unstable module 2023-02-01 17:55:07 +00:00
Jiahao XU
02c3699be2 Impl new mod read::stream
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-01 17:33:35 +00:00
Jiahao XU
16753209af Refactor: Extract ZipFileData::unix_mode
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-01 17:33:35 +00:00
Jiahao XU
a614d1f226 Refactor: Extract ZipFileData::enclosed_name
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-01 17:33:35 +00:00
Jiahao XU
08c2e76705 Fix param order in central_header_to_zip_file_inner
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-01 17:31:12 +00:00
Jiahao XU
e99c15471c Mv central header parsing to central_header_to_zip_file
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-01 17:31:12 +00:00
Jiahao XU
57440efa16 Refactor: Extract new fn central_header_to_zip_file_inner
that does not require `reader` to implement `io::Seek`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-01 17:31:12 +00:00
Mikael Pettersson
3fc54cf68c feat: Detect insufficient Dir record size
- Per zip spec 4.4.1.4 (https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT)
- If a CentralDirectoryEnd record field cannot hold the
  required data, a ZIP64 record must exist and the
  field will be set to -1(0xFFFF || 0xFFFFFFFF)
- Previously these archives were incorrectly detected as multi-disk
2023-01-30 11:13:01 +01:00
jkasari
7b83591f26 Add units to the size documentation.
The documentation did not list what it meant by "size". I changed it to
specify that it is returning the size in bytes.
2023-01-19 18:55:42 -08:00
Wyatt Herkamp
efd7f934ca Merge remote-tracking branch 'origin/master'
# Conflicts:
#	src/read.rs
2022-10-13 07:53:55 -04:00
Wyatt Herkamp
1c5cd4ffda Fixed new Clippy Warnings 2022-10-13 07:51:02 -04:00
Wyatt Herkamp
89e84e1032 Fixed new Clippy Warnings 2022-09-27 13:30:55 -04:00
Jiahao XU
80005fd2e1
Optimize inner of ZipArchive::extract
Rm generics in `inner`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 23:54:04 +10:00
Jiahao XU
6402eb0d22
Avoid dup monomorphization in ZipArchive::extract
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 23:50:34 +10:00
Jiahao XU
199796cbbf
Rm unnecessary p.exist() in ZipArchive::extract
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 23:48:48 +10:00
Dirk Stolle
e3d8f47708 Fix a few typos 2022-05-01 00:39:24 +02:00
Nick Babcock
03613cb56e Fix capacity overflow on invalid zips reads
Preemptively allocating structures with the number of reported files can
lead to trouble as an invalid zip can still have a valid central
directory end that is fed into a `with_capacity` causing it to overflow.

This commit introduces a heuristic that will use the reported number of
files as long as the number is less than the cde offset.

Benchmarks were unaffected by this change.
2022-04-25 21:01:56 -05:00
Pieter-Jan Briers
621971f078 Use some ::with_capacity when reading zip file.
Now with a proper benchmark
2022-04-11 16:17:20 +02:00
Pieter-Jan Briers
6b5628bef4 Use Seek.stream_position instead of seek(0).
BufReader can cache the result of stream_position() so it's fast, whereas seek(0) discards the read buffer and passes through straight to the OS. This drastically worsens the efficiency of loading performance when using BufReader (or anything else to avoid all these tiny reads going straight to the kernel).
2022-04-11 14:30:27 +02:00
Alexander Zaitsev
77294fd3ce
Revert "Merge pull request #290 from aweinstock314/more-spec-structs"
This reverts commit a1da6860ea, reversing
changes made to 574bb3df17.
2022-03-26 14:13:50 +03:00
Avi Weinstock
45a98c01b9 Cargo fmt and cargo clippy fixes. 2022-03-25 14:10:44 -04:00
Avi Weinstock
993cbcdc5c Add zip::spec::{CentralDirectoryHeader, DataDescriptor, LocalFileHeader}, and partially integrate them into zip::{read, write}. 2022-03-25 14:10:10 -04:00
Alexander Zaitsev
d8cfb2fd81
Merge branch 'master' into issue/281 2022-03-26 00:38:59 +03:00
Rouven Spreckels
00c1199dbe Use ZIP64_BYTES_THR and ZIP64_ENTRY_THR. 2022-03-25 16:01:56 +01:00
Alexander Zaitsev
7fa870c3b7
Merge branch 'master' into issue/281 2022-03-25 17:19:13 +03:00
Alexander Zaitsev
b0306318f1
docs: add a note about password handling 2022-03-25 17:13:19 +03:00
Дмитрий Кальянов
e8dabec5b6 Add support for specifying compression level 2022-03-23 13:06:28 +03:00
Marli Frost
2be9ae871f release: 0.6 2022-03-20 20:51:16 +00:00
Marli Frost
de8a9c5998 fix: remove Shared from public API 2022-03-20 19:01:43 +00:00
Alexander Zaitsev
ca60821c0a merge: Merge branch 'master' into explainer 2022-03-08 18:13:34 +03:00
Benoît du Garreau
214afdee81 Update doc comment 2022-02-06 23:29:35 +01:00
Benoît du Garreau
addfe01eb0 Make ZipArchive cheap to clone 2022-02-05 16:08:55 +01:00
Lireer
49f7501c5f add and use AES associated constant 2022-01-30 15:10:07 +01:00
Lireer
3a71893711 run cargo fmt 2022-01-25 20:57:27 +01:00
Lireer
35d8f04496 "fix" clippy warnings 2022-01-25 20:42:51 +01:00
Lireer
d7f0a182b6 Merge remote-tracking branch 'zip-rs/zip/master' 2022-01-25 17:48:45 +01:00
Marli Frost
f1074bc6a9 doc: remove re-exports section from crate root
Making the paths to the types private forces rustdoc to render
the structs inline in the crate root.
This is simpler to see when first reading the API doc
2022-01-23 21:45:41 +00:00
Alexander Zaitsev
63e714f622 Merge branch 'master' into feature/add_zstd_compression 2022-01-23 19:17:26 +03:00
Alexander Zaitsev
e636399935 fix: fix all Clippy warnings
- some warnings are muted since fixing them right now can be a breaking
  API change
- fix Clippy warns in the src, examples and tests

Tested:
- Local test run
2022-01-23 18:54:43 +03:00
Alexander Zaitsev
061cdf149f fix: fix Clippy warnings
- fix a bunch of Clippy warnings
- fix some usages of assert! (change to assert_ne)

Tested:
- Local unit-tests run
2022-01-23 17:35:27 +03:00
Alexander Zaitsev
0b82d905b3 feat: add Zstandard compression
- add dependency on zstd crate
- add zstd feature to Cargo.toml
- update README
- update example with Zstd
- add Zstd support to the library

Notes:
- This work is mainly based on this original PR: https://github.com/zip-rs/zip/pull/240

Tested:
- During the development of the original PR
2022-01-23 14:49:48 +03:00
Alexander Zaitsev
8a666b102b fix: add header offset overflow check
- during the header offset calculation, perform overflow check

Tested:
- Local tests
2022-01-22 17:56:13 +03:00
Lireer
75e8f6bab5 use less feature gates if no further dependencies are needed 2021-08-06 12:38:04 +02:00
Lireer
48b52a7e86 move AesMode and AesVendorVersion out of aes-crypto feature 2021-08-05 21:16:11 +02:00
Lireer
354993d906 feature gate aes decryption 2021-08-05 21:06:47 +02:00
Lireer
0820cc4fe2 fix more clippy warnings 2021-08-05 20:29:51 +02:00
Lireer
ff23539624 differentiate between ae1 and ae2 2021-08-05 20:28:14 +02:00