mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-25 20:14:31 +01:00
preview now reads a DISP chunk only when its first 4 bytes are 08 00 00 00 (every DISP chunk in the sample files starts so) and its bitmap has a 40-byte info header, a plane count of 1 and uncompressed pixels: compression 0 at 1, 4, 8, 16, 24 or 32 bits, or compression 3 (color masks) at 16 or 32 bits, as the bitmap info header page states. A color table may not hold more than 2^bit count colors, and the image size must be 0 or the rows' size, as in every sample. Other bit counts with those compressions fail as damaged; other header lengths and compressions are refused as unsupported. A DISP chunk of another kind, or a bitmap with another header length or compression, is passed over, and a file with no later DISP bitmap that preview reads is refused as unsupported. Before this, a bit count of 0, compression 6 or a header of another length gave a BMP file whose pixel offset was wrong, and the rows were checked only for compressions 0 and 3. The row size is now computed in 64 bits, so 32-bit targets accept the same bitmaps as 64-bit ones. The BMP file ends with the last row: bytes after it in the chunk are left out, and the file's memory is reserved fallibly. A RIFF file without a DISP bitmap now gives Ok(None) only when its last chunk ends where the form's length says, inside the file. A chunk that runs past the form, a partial chunk header at the end, a file cut short or a form length too short for the form type fails as damaged, since the missing bytes may hold the picture. A file cut short still gives a DISP chunk it holds whole. A version 2 file keeps a 1-bit picture (R40) that preview does not read, so preview refuses it as unsupported instead of reporting no picture. Version 1 still gives Ok(None). Tests cover each of these cases, a package that holds both thumbnail members, and the package member count limit. The hostile-input property tests in tests/it/read.rs now also run preview, including deflated thumbnail members and a compressed list before the DISP chunk, and check that a package without a picture member gives Ok(None) whatever its damaged drawing holds. The README and the preview doc comment say that preview does not check the drawing's version. PROVENANCE.md row R76 records that no sample package's RIFF stream has a DISP chunk, and the crate description mentions the preview.
24 lines
727 B
TOML
24 lines
727 B
TOML
[package]
|
|
name = "craft-cdr"
|
|
description = "Bounded reader for .cdr drawings of versions 1 to 27 and .cmx files: WL records, RIFF index, compressed lists, ZIP packages, shapes, fills, outlines, pages and layers, and the picture a file keeps of its drawing"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
rust-version.workspace = true
|
|
repository.workspace = true
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[features]
|
|
# Synthetic-file builders for tests and fuzz seeds; not a .cdr writer.
|
|
synth = []
|
|
|
|
[dependencies]
|
|
crc32fast = "1.5"
|
|
flate2 = { version = "1", default-features = false, features = ["rust_backend"] }
|
|
|
|
[dev-dependencies]
|
|
proptest = { workspace = true }
|
|
craft-cdr = { path = ".", features = ["synth"] }
|