DwgWriter: extended data over 32 767 bytes per application overflows its size; the object is lost on read
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 74/100
Research direction
Start by reading DwgObjectWriter.writeExtendedDataEntry around the reported WriteBitShort call, then trace how DwgReader reads extended data sizes. Reproduce with the provided LINE and 32,768-byte extended data, and compare with the 32,764-byte case. Done when writing handles values over the format limit without silently producing a file where the LINE disappears on read.
Written by the indexing model from the issue text.
Description
Describe the bug
DwgWriter writes the extended data of one application with a 16-bit size, without checking it. An entity whose extended data for one application is 32 768 bytes or longer is written without an error, but the size overflows. Read back with DwgReader, the object fails and is missing from the document. The log shows "Unknown code for extended data" warnings, then "Could not read LINE with handle: 73" with ArgumentException: An item with the same key has already been added. Key: 0.
DwgObjectWriter.writeExtendedDataEntry (master, v3.8.10), line 1163:
this._writer.WriteBitShort((short)mstream.Length);
To Reproduce
- A LINE with one
AppIdwhose records are 8 192 ×new ExtendedDataControlString(false)followed by 8 192 ×new ExtendedDataControlString(true)(2 bytes each, 32 768 bytes). DwgWriter.Write(path, doc)(AC1018; AC1015 and AC1032 behave the same).new DwgReader(path).Read(): the model space is empty.
With 8 191 + 8 191 records (32 764 bytes) the LINE reads back intact.
Expected behavior
Extended data over the format's limit is refused (or left out with a notification) when writing, rather than overflowing the size and losing the whole object on read.
Version
ACadSharp 3.8.0 (NuGet); same code on master.
- Dominant language
- C#
- Stars
- 873
- Forks
- 223
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 28
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DomCR/ACadSharp
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
-
DWG writer: text styles get the text-style table as their xref block handlePossibly taken @menes97 claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 81/100
Maintainers usually reply within 3 days
-
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 3 days
-
DwgWriter writes a null shape-file handle for SHAPE entities (WriteShapes = true)Possibly taken @menes97 claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
-
DwgReader reads a color-book entity's Color as ByBlock instead of the book's colorPossibly taken @menes97 claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
Similar issues
-
hand-to-AI
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
CactuseSecurity/firewall-orchestrator#5803 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
bug python
Difficulty 1/5 Under an hour Newbie friendliness 88/100
ilia-sokolov/OfficeAgent.NET#89 ·
Maintainers usually reply within 13 days