Commit Graph
14 Commits
Author SHA1 Message Date
Claude 03391c66cb Texture replacement: Support palette-indexed replacement images
- Fixes #15145

A replacement listed in a new [indexed] section of textures.ini holds
palette indices instead of colors: a palette PNG (the file's palette index)
or an 8-bit grayscale PNG (the gray value), at any resolution. When the
texture is built, the indices go through the game's current CLUT, including
the CLUT index shift, mask and start position, and the result is uploaded as
an ordinary RGBA texture. A game that swaps or customizes a palette keeps
working with a high-resolution replacement.

[indexed] keys use the [hashes] format and are matched with the same
wildcards, so a key with a zero CLUT hash covers every palette of the
texture. The contents hash only covers the indices, so one image is shared
by all palettes (the loaded data is shared, each palette still has its own
texture cache entry).

Saving does not dump indexed textures yet.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 21:42:39 +02:00
Acts1631 9ad3b821d9 Bound replacement PNG dimensions safely
Reject non-positive or oversized dimensions independently in the PNG

header peeker, matching the existing 8192 pixel decode limit. Use

checked size_t arithmetic before allocating replacement RGBA data so

crafted dimensions cannot overflow the allocation size.
2026-09-05 16:24:24 -04:00
Henrik Rydgård a7b1b319ce Limit PNG decode dimensions to prevent decompression bombs
pngLoadPtr allocated the decoded buffer directly from attacker-controlled
PNG IHDR dimensions with no upper bound, so browsing a crafted game icon
or savedata could trigger a multi-gigabyte allocation.

- Add maxWidth/maxHeight parameters to pngLoadPtr (default 8192x8192)
  and reject images larger than the limits.
- Thread the limits through LoadTextureLevelsFromFileData,
  CreateTextureFromFileData, and CreateTextureFromFile.
- Limit game icons to 256x128 in GameInfoCache and IconCache.
2026-08-01 11:41:24 +02:00
Henrik Rydgård cf28fd3a8d More cleanup in pngLoadPtr 2026-02-26 23:41:38 +01:00
Henrik Rydgård 48dc36be2e pngLoadPtr: Protect against over-reads from truncated files 2026-02-26 23:37:52 +01:00
刘皓 5716cbd41d Use the libretro VFS interface in libretro builds 2026-01-01 00:24:01 -05:00
Henrik Rydgård 947ddf865f Extract some duplicated code into a pngSave function 2025-09-15 11:46:54 -06:00
Henrik Rydgård 5adfe62fa3 libpng: Ignore benign errors. Should fix #20050 2025-03-01 23:46:40 +01:00
Henrik Rydgård d156a5e98f libpng full api: Remember to enable interlace handling, fix error handling
I hate hate hate libpng's API with all passion in the world. Why are all
the defaults wrong?
2025-02-26 10:55:03 -06:00
Henrik Rydgård 857c3393c0 Use libpng's full API so we can ignore gamma. Fixes Driver '76's icon. 2025-02-25 10:47:03 -06:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Henrik Rydgård 76c6058abe Texture replacer: Faster way to get width/height from a png 2023-03-07 22:20:56 +01:00
Henrik Rydgård 559ccd9f33 Minor cleanups 2020-12-14 20:06:06 +01:00
Henrik Rydgård 4f43cff5ca Move fileutil, net, image loaders, ui to Common. (#13506)
* Move and rename file_util/fd_util to Common/File/FileUtil and DirListing

Let's also move net while we're at it.

Move the ZIM/PNG loaders over to Common.

Move the UI framework into Common

iOS buildfix

* Buildfix

* Buildfixes

* Apple buildfix

* This typo again..

* UWP buildfix

* Fix build of PPSSPPQt, such as it is (it's not in good condition...)

* Guess what? Another buildfix.
2020-10-04 20:48:47 +02:00