Skip to content

Add Surface.Clear/Canvas.Clear, fix GetInfo/Load parity for TIFF and JPEG, and harden SvgCodec XXE settings explicitly - #17

Merged
Malcolmnixon merged 8 commits into
mainfrom
feature/surface-clear-getinfo-parity-xxe
Sep 25, 2026
Merged

Malcolmnixon merged 8 commits into
mainfrom
feature/surface-clear-getinfo-parity-xxe

Conversation

@Malcolmnixon

@Malcolmnixon Malcolmnixon commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Combines three related, low-risk downstream-feedback items ("Bundle A") into one PR, plus full companion artifacts (requirements, design docs, verification docs, user guide, unit + system tests).

1. Surface.Clear(Rgba32 color) / Canvas.Clear(Rgba32 color)

  • Adds a vectorized bulk-fill operation to Surface, following the same RowChannelBuffers/ReinterleaveRow/row-CopyTo broadcast-fill pattern already used by PremultiplyAlpha/CompositeOver - no naive per-pixel loop.
  • Adds Canvas.Clear(Rgba32 color) as a thin, transform-independent passthrough to Surface.Clear.

2. GetInfo must never fail on a file Load would accept

Fixes two violations of this design invariant:

  • TIFF: GetInfo(Stream) no longer throws NotSupportedException for a non-seekable stream. It now buffers the stream via the same ReadAllBytes/ByteArrayTiffDataSource path Load already uses, then runs the identical probe logic. The seekable fast path (StreamTiffDataSource) is unchanged. All existing malformed/unsupported-format exceptions are preserved.
  • JPEG: MaxProbeHeaderBytes (now internal const, testable via InternalsVisibleTo) becomes a soft cap. Once the incremental probe buffer would exceed it without finding SOF0/SOF2, GetInfo keeps scanning marker segments one at a time past the cap - never bulk-reading the stream remainder, and never reading past the boundary a given step actually needs - until a SOF0/SOF2 marker is found or one of two independent hard ceilings is hit: MaxProbeHeaderBytesHardLimit (16 MiB total bytes) or MaxProbeSegmentCount (512 non-terminating marker segments, counted only once the soft cap has actually been crossed, so a legitimate file entirely under the soft cap with many small metadata segments is never penalized). Load enforces the exact same two ceilings on its own pre-SOF marker-segment walk, so the two paths now genuinely agree on every input shape, not just an "already-accepted risk profile."
  • ImageInfo.cs and both codecs' GetInfo XML docs now explicitly state the invariant: "GetInfo never throws for an input that Load would successfully decode", with a reference to how each codec upholds it.
  • Existing tests/requirements that encoded the old (buggy) contract were rewritten/removed rather than merely supplemented (e.g., the old TiffCodec_GetInfo_NonSeekableStream_Throws* tests and their dedicated throwing-stream helper; the old JPEG probe-limit-exceeded tests whose message assertions no longer matched the new behavior).

3. Explicit XXE hardening in SvgCodec

  • Both XmlReaderSettings instances (LoadRootElement, LoadRootElementAttributesOnly) now explicitly set DtdProcessing = DtdProcessing.Prohibit and XmlResolver = null.
  • These were already the effective .NET defaults - this is a no-behavior-change, defense-in-depth documentation-through-code clarity fix, backed by new regression tests proving DOCTYPE-bearing (including external-entity) SVGs are rejected for both Load and GetInfo.

Companion artifacts

  • Reqstream requirements updated/added at unit, subsystem, and root/system rollup levels.
  • Design docs and verification docs updated for Surface, Rendering.Canvas, TiffCodec, JpegCodec, SvgCodec, and the root system verification doc.
  • User guide (docs/user_guide/introduction.md) updated for Clear and to correct stale GetInfo behavior descriptions.
  • Unit tests added/updated across SurfaceTests.cs, CanvasTests.cs, TiffCodecTests.cs, JpegCodecTests.cs, SvgCodecTests.cs.
  • 3 new CanvasNet_SystemIntegration_* system-level tests added to CanvasNetTests.cs per docs/verification/canvas-net.md's contract (root/system-level requirements require this evidence, not unit tests alone).
  • No SysML2 model or .reviewmark.yaml changes required - no software units were added/removed/reorganized.

Validation

  • pwsh ./fix.ps1 - clean, no diff.
  • pwsh ./lint.ps1 - passes cleanly (YAML, cspell/markdown, reqstream/versionmark/reviewmark/sysml2tools compliance checks, dotnet format --verify-no-changes).
  • pwsh ./build.ps1 - 0 warnings, 0 errors across net8.0/net9.0/net10.0.
  • Full test suite: 3834/3834 passed, 0 failed, 0 skipped (1278 per target framework x 3 TFMs).
  • Local code-review: PASS (no high-confidence bugs found in Surface.Clear, JPEG bulk-read fallback, TIFF buffering fallback, or SvgCodec XXE settings).
  • Formal review: PASS (one High finding in the first pass - a missing system-level verification-doc entry for the 3 new integration tests - was fixed and re-verified; approved).

…JPEG, and harden SvgCodec XXE settings explicitly

- Surface.Clear(Rgba32): vectorized broadcast-fill bulk pixel operation, matching the
  existing PremultiplyAlpha/CompositeOver row-buffer pattern. Canvas.Clear(Rgba32) added
  as a thin, transform-independent passthrough.
- TiffCodec.GetInfo: buffers non-seekable streams via the same ReadAllBytes/ByteArrayTiffDataSource
  path Load already uses, instead of throwing NotSupportedException.
- JpegCodec.GetInfo: MaxProbeHeaderBytes becomes a soft cap (internal const) - once reached
  without finding SOF0/SOF2, falls back to a one-time bulk read of the stream remainder and
  continues scanning, matching Load's own unbounded buffering, instead of throwing.
- ImageInfo.cs and both codecs' GetInfo XML docs now state the invariant: GetInfo never
  throws for an input that Load would successfully decode.
- SvgCodec.cs: explicit DtdProcessing.Prohibit / XmlResolver = null on both XmlReaderSettings
  instances (already-safe .NET defaults, made explicit for defense-in-depth clarity; no
  behavior change).
- Full companion artifacts: reqstream requirements (unit/subsystem/system rollups), design
  docs, verification docs, user guide updates, unit tests, and 3 new
  CanvasNet_SystemIntegration_* system-level regression tests.
Copilot AI lite review requested due to automatic review settings September 25, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Address the JPEG stream-draining issue and strengthen the affected parity and system-level verification tests.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Adds Surface.Clear/Canvas.Clear, improves TIFF/JPEG GetInfo parity, and explicitly hardens SVG XML parsing.

Changes:

  • Adds vectorized clear operations.
  • Adds TIFF buffering and JPEG fallback behavior.
  • Adds SVG XXE protections, tests, and documentation updates.
File Summary
test/​DemaConsulting.CanvasNet.Tests/​TestSupport/​NonSeekableStream.cs Updates stream helper documentation.
test/​DemaConsulting.CanvasNet.Tests/​Rendering/​CanvasTests.cs Tests Canvas.Clear.
test/​DemaConsulting.CanvasNet.Tests/​Codecs/​TiffCodecTests.cs Tests non-seekable TIFF probing.
test/​DemaConsulting.CanvasNet.Tests/​Codecs/​SvgCodecTests.cs Tests SVG DTD rejection.
test/​DemaConsulting.CanvasNet.Tests/​Codecs/​JpegCodecTests.cs Tests JPEG fallback behavior.
test/​DemaConsulting.CanvasNet.Tests/​CanvasNetTests.cs Adds system integration tests.
test/​DemaConsulting.CanvasNet.Tests/​Canvas/​SurfaceTests.cs Tests surface clearing.
src/​DemaConsulting.CanvasNet/​Rendering/​Canvas.cs Adds Canvas.Clear.
src/​DemaConsulting.CanvasNet/​Codecs/​TiffCodec.cs Buffers non-seekable streams.
src/​DemaConsulting.CanvasNet/​Codecs/​SvgCodec.cs Adds explicit XML hardening.
src/​DemaConsulting.CanvasNet/​Codecs/​JpegCodec.cs Adds JPEG soft-cap fallback.
src/​DemaConsulting.CanvasNet/​Codecs/​ImageInfo.cs Documents probing parity.
src/​DemaConsulting.CanvasNet/​Canvas/​Surface.cs Implements vectorized clearing.
docs/​verification/​canvas-net/​rendering/​canvas.md Documents Canvas verification.
docs/​verification/​canvas-net/​codecs/​tiff-codec.md Documents TIFF verification.
docs/​verification/​canvas-net/​codecs/​svg-codec.md Documents SVG security verification.
docs/​verification/​canvas-net/​codecs/​jpeg-codec.md Documents JPEG verification.
docs/​verification/​canvas-net/​canvas/​surface.md Documents surface-clear verification.
docs/​verification/​canvas-net.md Adds system scenarios.
docs/​user_guide/​introduction.md Documents APIs and probing behavior.
docs/​reqstream/​canvas-net/​rendering/​canvas.yaml Adds Canvas requirements.
docs/​reqstream/​canvas-net/​rendering.yaml Updates rendering requirements.
docs/​reqstream/​canvas-net/​codecs/​tiff-codec.yaml Updates TIFF requirements.
docs/​reqstream/​canvas-net/​codecs/​svg-codec.yaml Adds SVG security requirements.
docs/​reqstream/​canvas-net/​codecs/​jpeg-codec.yaml Updates JPEG requirements.
docs/​reqstream/​canvas-net/​codecs.yaml Updates codec rollups.
docs/​reqstream/​canvas-net/​canvas/​surface.yaml Adds Surface requirements.
docs/​reqstream/​canvas-net/​canvas.yaml Updates Canvas requirements.
docs/​reqstream/​canvas-net.yaml Updates system requirements.
docs/​design/​canvas-net/​rendering/​canvas.md Documents Canvas design.
docs/​design/​canvas-net/​codecs/​tiff-codec.md Documents TIFF fallback.
docs/​design/​canvas-net/​codecs/​svg-codec.md Documents XML hardening.
docs/​design/​canvas-net/​codecs/​jpeg-codec.md Documents JPEG fallback.
docs/​design/​canvas-net/​codecs.md Updates codec architecture.
docs/​design/​canvas-net/​canvas/​surface.md Documents the clear algorithm.
.cspell.yaml Adds technical terminology.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

…(PR #17 review round 1)

- JpegCodec: IncrementalProbeBuffer no longer bulk-drains the stream to EOF
  once MaxProbeHeaderBytes is crossed without finding SOF0/SOF2. It now
  continues scanning segment-by-segment past the soft cap, bounded to
  exactly what each request needs, so GetInfo stops the instant SOF0/SOF2
  is found and never reads entropy-coded scan data, even for streams with
  unusually large leading metadata or streams that never reach EOF.
- Added JpegCodec_GetInfo_SofShortlyAfterProbeCap_StopsAtSofWithoutDrainingStream
  and a new InfiniteTailStream test double, proving the fix (and failing
  against the old bulk-drain behavior).
- TiffCodecTests: fixed TiffCodec_GetInfo_NonSeekableStream_SucceedsAndMatchesLoadResult
  to genuinely verify GetInfo/Load parity by comparing against
  TiffCodec.Load's decoded Surface dimensions, instead of comparing two
  GetInfo calls against each other.
- Updated companion design/requirements/verification/user-guide docs and
  .reviewmark.yaml to keep them consistent with the corrected behavior.
Copilot AI review requested due to automatic review settings September 25, 2026 14:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The JPEG probing path has unresolved critical and moderate resource-consumption findings.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (2)

…17 review round 2)

Fixes a High severity finding: after the previous review round made
JpegCodec.GetInfo's post-soft-cap (MaxProbeHeaderBytes, 1 MiB) fallback
scan continue segment-by-segment instead of bulk-draining the stream,
that scan had no upper bound at all besides genuine end-of-stream -
reintroducing a denial-of-service vector for a malformed/no-SOF JPEG or
a slow/infinite stream.

Adds a new internal const MaxProbeHeaderBytesHardLimit (16 MiB, 16x the
soft cap): IncrementalProbeBuffer.TryEnsureLength now refuses outright
once a request would require buffering more than that hard ceiling,
and ProbeDimensions/GetInfo throws InvalidDataException once it is
reached without a SOF0/SOF2 marker ever being found, rather than
reading or buffering data without bound. The soft cap's existing
continue-past-the-cap behavior for legitimately large leading metadata
(e.g. large ICC/XMP blocks) is preserved unchanged below the new hard
limit.

Adds a regression test reusing the existing InfiniteTailStream/
BoundedReadStream test doubles to prove the hard limit is enforced
(and completes quickly rather than hanging or reading unboundedly),
and verifies the existing SofShortlyAfterProbeCap regression test is
unaffected. Updates the companion reqstream requirements, design, and
verification documentation, and the user guide, to describe the new
two-tier soft-cap/hard-limit design.
Copilot AI review requested due to automatic review settings September 25, 2026 15:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved JPEG GetInfo/Load parity and related contract, documentation, and traceability issues remain.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 3 Medium severity

Open (4)
Resolved since last review (1)

Comment thread docs/reqstream/canvas-net.yaml Resolved
Comment thread docs/reqstream/canvas-net.yaml Resolved
 round 3)

Adds JpegCodec.MaxProbeSegmentCount (512) as a second, independent
resource ceiling on ProbeDimensions' post-soft-cap fallback scan,
alongside the existing byte-based MaxProbeHeaderBytesHardLimit
(16 MiB). A JPEG marker segment can be as small as 4 bytes, so the
byte-based hard limit alone would not cheaply bound the number of
scan iterations for a malformed stream built from many minimal-size
segments (up to ~4 million iterations before the byte cap trips).
The new segment-count cap bounds iterations directly.

The check is applied only to non-terminating segments (stray restart
markers and the general APPn/COM/DQT/DHT/etc. fallback path) and
never to the terminating SOF0/SOF2 marker segment itself, so a
well-formed file whose SOF marker happens to land exactly on what
would otherwise be the limit-exceeding segment still probes
successfully - preserving the 'GetInfo never throws for an input
Load would successfully decode' invariant.

Adds two regression tests:
- JpegCodec_GetInfo_ManyMinimalSegmentsNoSof_StopsAtSegmentCountLimitBeforeByteLimit
  proves the segment-count cap (not the byte cap) catches a
  many-minimal-segment attack shape well before the byte-based
  hard limit could ever be approached.
- JpegCodec_GetInfo_SofAsSegmentImmediatelyAfterSegmentCountLimit_StillSucceeds
  proves the segment-count cap never rejects a well-formed file
  whose SOF marker lands exactly on the boundary segment.

Updates companion documentation (reqstream requirements, design doc,
verification doc test counts/narrative, user guide) to describe the
new cap and both new tests. Both local code-review and formal-review
passed (an initial formal-review round caught and this commit fixes
a High-severity off-by-one boundary defect in the first draft of the
segment-count check).

All 3,819 tests pass (net8.0/net9.0/net10.0).
Copilot AI review requested due to automatic review settings September 25, 2026 18:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Moderate findings remain around JPEG GetInfo/Load parity and corresponding contract and requirement documentation.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 4 Medium severity

Open (5)

…as.Clear system test (PR #17 review round 4)

Responds to 4 new cloud-review findings on PR #17:

Finding A (High): JpegCodec.GetInfo's MaxProbeHeaderBytesHardLimit (16 MiB) and
MaxProbeSegmentCount (512) ceilings break the documented "GetInfo never throws for an
input Load would successfully decode" parity invariant, since Load enforces no
equivalent ceiling (it buffers the entire stream unconditionally via ReadAllBytes).
Per an explicit prior team decision NOT to add a matching cap to Load (out of scope -
a separate, previously deferred concern about Load's own unbounded-size read), this
is resolved by narrowing and explicitly documenting the invariant instead:

- ImageInfo.cs: added a new remarks paragraph documenting this as a deliberate,
  narrow, explicitly-accepted exception to the general "GetInfo never throws for an
  input Load would accept" invariant, naming both ceilings.
- JpegCodec.cs: added a matching <remarks> block on GetInfo(Stream) stating the same
  narrowed invariant precisely, worded as an intentional design decision.
- docs/reqstream/canvas-net.yaml: updated the root CanvasNet-Lib-JpegGetInfo
  requirement's title/justification, which previously (inaccurately) said GetInfo
  throws "only when the stream genuinely ends" - now describes both hard ceilings as
  a documented, narrow parity exception. Added the new proof test to its tests: list.
- New regression test JpegCodec_GetInfoVsLoad_LeadingMetadataExceedsHardLimit_IsAcceptedParityException
  (JpegCodecTests.cs): builds leading APP0 filler segments comfortably exceeding
  MaxProbeHeaderBytesHardLimit before a genuinely valid, decodable SOF0/SOS/entropy
  tail, and asserts Load succeeds while GetInfo on the identical bytes throws
  InvalidDataException referencing the hard limit - proving the divergence is real,
  intentional, and narrowly scoped, not a regression.
- Updated companion design doc (new architectural-decision subsection), verification
  doc (new test narrative + tests: list entry), and user guide prose to match.

Finding B: docs/reqstream/canvas-net.yaml's root CanvasNet-Lib-CanvasClear
requirement's only system-level test evidence exercised Surface.Clear directly;
Canvas.Clear (the Rendering.Canvas -> Surface passthrough) was only exercised by
Rendering unit tests, so a regression in the passthrough could leave the root
requirement green. Added a new system integration test
CanvasNet_SystemIntegration_CanvasClearThenReadWrappedSurfacePixel_ReturnsExpectedColor
(CanvasNetTests.cs) that constructs a Rendering.Canvas wrapping a Surface, calls
Canvas.Clear, and reads pixels back directly from the wrapped Surface reference (not
just via Canvas) to prove the passthrough genuinely reaches the underlying buffer.
Added this test to the CanvasNet-Lib-CanvasClear tests: list alongside (not
replacing) the existing Surface.Clear-only evidence, and added a matching new
section to docs/verification/canvas-net.md (scenario count 23 -> 24).

Verification:
- Build: 0 warnings/errors across net8.0/net9.0/net10.0.
- Full test suite: 3825/3825 passed (3819 baseline + 2 new tests x 3 TFMs).
- pwsh ./fix.ps1 and pwsh ./lint.ps1: both clean.
- Local code-review: PASS.
- Local formal-review: PASS (0 Critical/High/Medium/Low blocking issues; 1
  informational-only stylistic note, not actionable).
Copilot AI review requested due to automatic review settings September 25, 2026 18:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Address the unresolved JPEG probing over-read and buffer-growth issues before approval.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
Resolved since last review (4)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Probe reads past SOF into entropy-coded scan data

src/​DemaConsulting.CanvasNet/​Codecs/​JpegCodec.cs:1081

This pre-cap branch still reads a full 4,096-byte chunk even when only a few bytes are needed to reach the next marker or the end of the SOF segment. If SOF is near a chunk boundary, GetInfo therefore consumes bytes after SOF (including entropy-coded data), contrary to the method/requirements contract that the probe never reads scan data and stops at the parsed SOF. Bound the chunk by requiredLength - Length as well as the soft-cap remainder.

Low severity PR description contradicts shipped probing behavior

src/​DemaConsulting.CanvasNet/​Codecs/​JpegCodec.cs:1100

The PR description says that crossing the soft cap triggers a one-time bulk read of the stream remainder, but this implementation intentionally scans segment-by-segment and stops at the next requested boundary, with additional hard byte/segment ceilings. That is a materially different resource and parity contract (it does not bulk-read the remainder and can still reject before EOF); update the PR description to match the shipped behavior and its documented exception.

…Info/Load parity

- Add MaxProbeSegmentCount (512) as a defense-in-depth segment-count
  ceiling in GetInfo's post-SOI probe walk, independent of the existing
  byte-based MaxProbeHeaderBytesHardLimit (16 MiB). Bounds worst-case
  loop iterations directly, since a malformed stream of many minimal
  4-byte segments could otherwise take ~4M iterations before the byte
  cap trips.
- Reverse the previously-shipped "documented accepted exception" for
  Load vs GetInfo divergence on pathological >16 MiB leading-metadata
  JPEGs. Instead, extend both MaxProbeHeaderBytesHardLimit and the new
  MaxProbeSegmentCount to Load's own Decoder.Decode segment walk, so
  Load and GetInfo now throw InvalidDataException consistently - true,
  unconditional parity rather than a documented carve-out.
- Add CountsTowardSegmentLimit(marker) helper mirroring exactly which
  marker kinds ProbeDimensions' segment-count check counts (excludes
  SOF0/SOF2, SOS, and unsupported-SOF/frame markers), so Load and
  GetInfo never diverge on exception *message* at segment-count
  boundaries, not just exception type.
- Fix an ordering bug in Decode's ceiling checks: capture
  state.SofSeen *before* calling ProcessSegment (not the live
  post-segment value), since ProcessSegment sets SofSeen=true while
  processing the SOF segment itself - using the post-segment value
  wrongly exempted the terminating SOF segment's own bytes from the
  byte-limit check.
- Update ImageInfo.cs and JpegCodec.cs XML docs, reqstream files
  (root/subsystem/unit), design doc, verification doc, and user guide
  to describe true parity (no carve-out language).
- Add/update tests: JpegCodec_GetInfoVsLoad_LeadingMetadataExceedsHardLimit_BothThrowConsistently,
  JpegCodec_GetInfoVsLoad_LeadingSegmentCountExceedsLimit_BothThrowConsistently,
  JpegCodec_GetInfoVsLoad_SofSegmentStraddlesHardLimit_BothThrowConsistently,
  JpegCodec_GetInfoVsLoad_SosBeforeSofAtSegmentCountBoundary_BothThrowSosMessageNotSegmentLimit.

3834/3834 tests passing (net8.0/net9.0/net10.0). Local code-review and
formal-review both PASS.
Copilot AI review requested due to automatic review settings September 25, 2026 19:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Two moderate JPEG performance findings and three nits remain unresolved.

Review effort: Lite
Findings: None

Resolved since last review (5)

… review round 6)

- Gate the MaxProbeSegmentCount check (both GetInfo's ProbeDimensions
  and Load's Decode) so it is a no-op until the soft cap has already
  been crossed. Previously it counted from segment #1 unconditionally,
  incorrectly rejecting legitimate files under the 1 MiB soft cap that
  simply have many small metadata segments.
- Bound IncrementalProbeBuffer's pre-soft-cap chunk reads by the actual
  remaining bytes needed (target - Length) instead of the soft cap
  remainder, preventing GetInfo from reading a full 4096-byte chunk -
  and potentially into entropy-coded scan data - when only a few bytes
  are needed to reach the next marker or the SOF segment boundary.
- Update the four JPEG segment-count regression tests to build leading
  filler that crosses the soft cap before exercising the segment-count
  cap, matching the corrected behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 25, 2026 20:13
@Malcolmnixon

Copy link
Copy Markdown
Member Author

Round 6 fix (�f26d88):

  • Gated the MaxProbeSegmentCount check (both GetInfo's ProbeDimensions and Load's Decode) so it's a no-op until the soft cap has already been crossed - it previously counted from segment Bump the nuget-dependencies group with 2 updates #1 unconditionally, incorrectly rejecting legitimate files under the 1 MiB soft cap with many small metadata segments.
  • Bounded IncrementalProbeBuffer's pre-soft-cap chunk reads by the actual remaining bytes needed instead of the soft-cap remainder, so GetInfo no longer reads a full 4096-byte chunk - potentially into entropy-coded scan data - when only a few bytes are needed to reach the next marker or the SOF boundary.
  • Updated the PR description's JPEG section to describe the actual shipped segment-by-segment scan (not the earlier 'bulk read of stream remainder' description).
  • Rewrote the four affected segment-count regression tests to build leading filler that crosses the soft cap before exercising the segment-count cap, matching the corrected behavior.

3834/3834 tests pass across net8.0/net9.0/net10.0.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The JPEG capacity-growth concern and SVG verification-evidence mismatch remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity · 1 Low severity

Open (2)
Resolved since last review (1)

…ation doc overclaim (PR #17 review round 7)

- IncrementalProbeBuffer.EnsureCapacity now grows the backing array
  geometrically (doubling, capped at hardLimit) instead of resizing to
  the exact capacity needed on every post-soft-cap read step. Growing
  in ~200 fixed 80 KiB steps toward the 16 MiB hard limit previously
  copied the entire buffer on each resize; doubling makes the total
  copying amortized linear instead of quadratic.
- Corrected docs/verification/canvas-net/codecs/svg-codec.md's XXE
  hardening section, which overclaimed test coverage: no test exercises
  an external parameter entity (only a general entity is tested), and
  the tests demonstrate rejection of the DOCTYPE-bearing document, not
  (via a resolver spy or similar) that no external fetch is attempted -
  that guarantee rests on .NET's documented DtdProcessing.Prohibit
  behavior, not on anything the tests themselves observe.

3834/3834 tests pass across net8.0/net9.0/net10.0.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 25, 2026 20:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved moderate findings remain in JPEG probing and root requirement traceability, alongside minor wording fixes.

Review effort: Lite
Findings: None

Resolved since last review (2)

@Malcolmnixon
Malcolmnixon merged commit 04dc90a into main Sep 25, 2026
7 checks passed
@Malcolmnixon
Malcolmnixon deleted the feature/surface-clear-getinfo-parity-xxe branch September 25, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants