Repository navigation
Never crash: the deep watermark clips to its buffer, a rating above five is clamped like the sidecar's, and unserialisable settings are left out of a sidecar - #1850
Merged
Conversation
A high-bit-depth image whose sample buffer is shorter than width x height x 3 (a hand-built or truncated DeepImage; the fields are public) made the 16-bit and float watermark paths index `v[i + c]` past the end and panic. Both paths now take the pixel as `get_mut(i..i + 3)` with saturating index math and skip pixels the buffer does not have. Test: deep_watermark_survives_a_sample_buffer_shorter_than_its_size marks buffers of length 0, 1, 2, 3, half, half+1, full-2, full-1 and full for both sample types (and through the alpha path); it panics with the old indexing. Manual: none, no user-visible change Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A stored rating above 5 was narrowed with `as i8` in the export metadata: 6 to 127 were written as that many stars and 128 to 255 went negative, which a sidecar reader takes for Reject (the sidecar writer already clamped with `.min(5)`). One `sidecar::file_rating` now narrows a rating for the sidecar packet and the exported file alike: 0 writes nothing to a file, 1 to 5 are kept, anything larger is five. Test: a_rating_above_five_is_written_as_five_stars covers 0, 1, 4, 5, 6, 127, 128, 200 and 255 through export_metadata, the XMP it writes, and the export sidecar packet read back (rating and no Reject); it fails at 6 with the old cast. Manual: none, no user-visible change Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…f a sidecar, not written empty
The sidecar packet turned a failed serialisation of the develop settings
(a value with no JSON form) into an empty string with `unwrap_or_default()`
and wrote it as `lc:settings`, which every reader takes for "no settings"
with no word anywhere. Both sites (settings with and without a plug-in
filter stack) now go through `settings_json`: a failure is logged and the
packet carries no `lc:settings`. Settings that serialise (non-finite numbers
become JSON null) are written as before.
Test: settings_that_cant_be_serialised_are_left_out_not_written_empty feeds a
failing Serialize and a pair-keyed map (None), a NaN/inf list (written as
null) and the photo's real settings (still in the packet); the first two
return Some("") with the old fallback.
Manual: none, no user-visible change
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The new deep-watermark test passes the floor scale that staging's draw_watermark_deep_over now takes (emmertex#1848). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
emmertex
enabled auto-merge
December 2, 2026 19:53
Owner
|
Merged |
This was referenced Dec 3, 2026
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.
In short: three places in export where a number or a value from a stored library could be turned into something wrong or a panic-shaped slice, each now bounded and pinned by a test.
Change
&mut v[i..i + 3]from a sample buffer whose length they never checked; a buffer shorter than the image (a short decode) would panic. They now useget_mut(i..i + 3)with saturating index math and clip to the samples there are.photo.rating as i8. A stored rating of 6 to 127 was written as that many stars and 128 to 255 went negative, which the sidecar reader takes for Reject. A newsidecar::file_rating(min(5)) is the one narrowing both use.unwrap_or_default()the develop settings serialisation, so a failure would write an emptylc:settings. Both go through asettings_jsonhelper that logs a warning and leaveslc:settingsout instead. Valid settings behave as before; a merge into an existing sidecar replaces the oldlc:*settings as it did with the empty string. Serialising the settings practically cannot fail today (NaN becomes null), so this is hardening.How it was checked
deep_watermark_survives_a_sample_buffer_shorter_than_its_size(buffer lengths 0, 1, 2, 3, half, half+1, full-2, full-1 and full, for 16-bit and float and the alpha path),a_rating_above_five_is_written_as_five_stars(0, 1, 4, 5, 6, 127, 128, 200, 255; reads the sidecar packet back: rating five, no Reject),settings_that_cant_be_serialised_are_left_out_not_written_empty. Each fails with the old code put back (the first panics with "range start index 43698 out of range for slice of length 0"). 359 engine export, sidecar and metadata tests pass.cargo xtask ci --quick --base origin/stagingon this branch (macOS): fmt, brand, quarantine, docs, notes, i18n, windows, clippy and stamp pass. Tests of lcc-engine: all pass exceptdevice_sync::tests::a_shared_collection_brings_photos_files_and_edits_both_ways(environmental on that machine; it also fails on plainstagingthere). Parity, layers, assets, wasm and deny: pass.🤖 Generated with Claude Code