Repository navigation
fix(writer): emit the §4.1 header fields real R2004-family files carry - #259
Merged
Merged
Conversation
assemble_dwg_bytes wrote a CRC-valid encrypted file-header block but
none of §4.1's fixed fields. Every real R2004, R2010, R2013 and R2018
file checked carries the long 0x80 at plain 0x28; 0x6C, 4, 1, 0x20,
0x80 and 0x40 at decrypted 0x10, 0x14, 0x24, 0x44, 0x48 and 0x4C; and
in the 0x14 bytes after the block the magic sequence continued to 0x100
("copied from the magic number sequence, starting at 0x100 - 0x14").
The fixtures carried zeros. The writer now emits them, using
cipher::header_trailer for the trailing bytes; the CRC is computed after
them as before.
The four R2004-family fixtures are regenerated; only bytes 0x28-0xFF
of each change, and decoded entities and offsets are unchanged (25/0/0,
every handle-map entry resolved). The second header copy and the LZ77
stream framing (#163) remain as they were.
Closes #233
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The writer now emits the §4.1 fixed file-header fields every real R2004-family file carries, and the four R2004-family canonical fixtures are regenerated. Closes #233.
Spec reference
ODA Open Design Specification for .dwg files v5.4.1, §4.1: plain 0x28 "0x00000080"; decrypted 0x0C "0x00", 0x10 "0x6c", 0x14 "0x04", 0x24 "Unknown long (ODA writes 1)", 0x44 "0x20", 0x48 "0x80", 0x4C "0x40"; and "The next 0x14 bytes will be copied from the magic number sequence, starting at 0x100 – 0x14".
assemble_dwg_byteswrote a CRC-valid block with none of these.cipher::header_trailerruns the §4.1 generator on to 0x100 bytes for the trailing 0x14; the block CRC is still computed after every field is set.Test plan
cargo run --release --example build_fixtures: deterministic (two runs, identical SHA-256), byte-identical to this commit. Only bytes 0x28–0xFF of each R2004-family fixture change (31 bytes each);synthetic_2000.dwgis untouched.coverage_report tests/fixtures/canonical: 25 / 0 / 0, every handle-map entry resolved, no handle disagreeing with the map.sample_AC1032.dwg; the CRC-32 still verifies.cargo test --release --all-featureswith the 19-file real corpus: all suites pass, nothing prints "skipping"; fmt and clippy clean.verify_lz77.pypasses on the regenerated fixtures (page contents are unchanged; only header bytes moved).feat/streaming-r2004-header) accepts the regenerated fixtures; it rejected the old ones.Not in scope: the second header copy at the end of the file (address stays 0) and the LZ77 framing on #163.
Source-provenance declaration
Clean-room declaration. All code in this PR was written from scratch. The only sources consulted were this repository and the ODA's public Open Design Specification for .dwg files v5.4.1. No Autodesk SDK, ODA SDK (Drawings / Teigha), LibreDWG or other copyleft DWG implementation source, and no decompilation, was consulted. Spec citations are in the diff.