mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:20:53 +01:00
[PR #1601] amd_swizzle: reject impossible sizes, unusable offsets and empty results #1617
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1617
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1601
Author: @xel1uz
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/amd-swizzle-argument-guards📝 Commits (1)
672dba7amd_swizzle: reject impossible sizes, unusable offsets and empty results📊 Changes
2 files changed (+98 additions, -2 deletions)
View changed files
📝
tests/test_amd_swizzle.py(+73 -0)📝
tools/amd_swizzle.py(+25 -2)📄 Description
Item ID:
AMD-SWIZZLE-ARG-GUARDS(new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here)Claimed as:
AMD-SWIZZLE-ARG-GUARDS-tools/amd_swizzle.pydies with a raw traceback on--width 0or a negative size, and silently exits 0 with no output when--offsetor--modescannot produce an image. Reproduced onc7e82e26with a synthetic addrlib header and a 256-byte blob.What and why
On
c7e82e26the tool validated only--outand the blob path, so every other bad argument ended in one of four ways:--width 0/--height 0reached Pillow:PIL.UnidentifiedImageError: cannot identify image file.--width -4reached numpy:ValueError: negative dimensions are not allowed.--offset -1silently sliced the blob from the end;--offset 999(past the end of a 256-byte blob) left an empty buffer. Both exited 0, printed nothing and wrote no image, so a caller could not tell either from a mistyped value.--modesvalue matching no pattern table printed nothing and exited 0.<ref>\mesa-addrlib\gfx10SwizzlePattern.h), so on a host without that file the tool died in a rawFileNotFoundErrortraceback instead of namingAMD_SWIZZLE_HEADER.Each case now prints one
ERROR:line and exits 2 before any work starts, in the same shape as the existing--outguards. A missing or malformed header is reported as such. Valid runs are untouched.Tested
python -m pytest tests/test_amd_swizzle.py -q-> 20 passed, 8 subtests passed (pytest 9.2.0, numpy 2.5.5, Pillow 13.0.0 on Linux).git diff --checkclean;python -I scripts/check_no_game_data.py tools/amd_swizzle.py tests/test_amd_swizzle.pyexits 0.GPUs tested: n/a - CPU only, no Vulkan device involved.
AI-assisted: Yes.
Checklist
main(c7e82e26) and merges cleanly.docs/design.md- not applicable, no translator change.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.