Commit 1865822
committed
fix(psd): fixes against corrupt files with better validation
* Validate channel count against color mode to prevent heap buffer
overflow.
* Corrupted PSD files can declare a color mode (e.g. RGB, needing 3
channels) with transparency (needing +1) but report fewer channels
in the header. This caused an out-of-bounds read in
read_native_scanline when setup() built channel pointer arrays using
mode_channel_count, which exceeded the actual
m_image_data.channel_info size.
Used Claude Code / Opus 4.6 to help narrow down and confirm the bug.
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 92c6c68 commit 1865822
6 files changed
Lines changed: 61 additions & 23 deletions
File tree
- src/psd.imageio
- testsuite/psd
- ref
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1468 | 1468 | | |
1469 | 1469 | | |
1470 | 1470 | | |
1471 | | - | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
1472 | 1474 | | |
1473 | 1475 | | |
1474 | 1476 | | |
| |||
1853 | 1855 | | |
1854 | 1856 | | |
1855 | 1857 | | |
1856 | | - | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
1857 | 1861 | | |
1858 | 1862 | | |
1859 | 1863 | | |
| |||
1894 | 1898 | | |
1895 | 1899 | | |
1896 | 1900 | | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
1897 | 1917 | | |
1898 | 1918 | | |
1899 | 1919 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1467 | 1467 | | |
1468 | 1468 | | |
1469 | 1469 | | |
1470 | | - | |
1471 | | - | |
1472 | | - | |
1473 | | - | |
1474 | | - | |
1475 | | - | |
1476 | | - | |
1477 | | - | |
1478 | 1470 | | |
1479 | 1471 | | |
1480 | 1472 | | |
| |||
2098 | 2090 | | |
2099 | 2091 | | |
2100 | 2092 | | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1467 | 1467 | | |
1468 | 1468 | | |
1469 | 1469 | | |
1470 | | - | |
1471 | | - | |
1472 | | - | |
1473 | | - | |
1474 | | - | |
1475 | | - | |
1476 | | - | |
1477 | | - | |
1478 | 1470 | | |
1479 | 1471 | | |
1480 | 1472 | | |
| |||
2098 | 2090 | | |
2099 | 2091 | | |
2100 | 2092 | | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | 22 | | |
28 | 23 | | |
29 | 24 | | |
30 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
Binary file not shown.
Binary file not shown.
0 commit comments