Skip to content

Commit 931148f

Browse files
authored
Merge branch 'AcademySoftwareFoundation:main' into R3D
2 parents abeed56 + aaa599b commit 931148f

File tree

9 files changed

+34
-3
lines changed

9 files changed

+34
-3
lines changed

src/cmake/compiler.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ set (EXTRA_DSO_LINK_ARGS "" CACHE STRING "Extra command line definitions when bu
617617
###########################################################################
618618
# Set the versioning for shared libraries.
619619
#
620-
if (${PROJECT_NAME}_SUPPORTED_RELEASE)
620+
if (${PROJECT_NAME}_SUPPORTED_RELEASE AND NOT SKBUILD)
621621
# Supported releases guarantee ABI back-compatibility within the release
622622
# family, so SO versioning is major.minor.
623623
set (SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}

src/ico.imageio/icoinput.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ ICOInput::seek_subimage(int subimage, int miplevel)
190190
swap_endian(&subimg.numColours);
191191
}
192192

193+
// some sanity checking
194+
if (subimg.bpp != 1 && subimg.bpp != 4 && subimg.bpp != 8
195+
&& subimg.bpp != 16 && subimg.bpp != 24 && subimg.bpp != 32) {
196+
errorfmt("Unsupported image color depth, probably corrupt file");
197+
return false;
198+
}
199+
if (subimg.reserved != 0) {
200+
errorfmt(
201+
"Probably corrupt file (clue: header 'reserved' value should always be 0)",
202+
subimg.reserved);
203+
return false;
204+
}
205+
193206
ioseek(subimg.ofs, SEEK_SET);
194207

195208
// test for a PNG icon

src/rla.imageio/rlainput.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,15 @@ RLAInput::decode_channel_group(int first_channel, short num_channels,
604604
// OIIO conventions.
605605
if (num_bits == 8 || num_bits == 16 || num_bits == 32) {
606606
// ok -- no rescaling needed
607-
} else if (num_bits == 10) {
607+
}
608+
int bytes_per_chan = ceil2(std::max(int(num_bits), 8)) / 8;
609+
if (size_t(offset + (m_spec.width - 1) * pixelsize
610+
+ num_channels * bytes_per_chan)
611+
> m_buf.size()) {
612+
errorfmt("Probably corrupt file (buffer overrun avoided)");
613+
return false; // Probably corrupt? Would have overrun
614+
}
615+
if (num_bits == 10) {
608616
// fast, common case -- use templated hard-code
609617
for (int x = 0; x < m_spec.width; ++x) {
610618
uint16_t* b = (uint16_t*)(&m_buf[offset + x * pixelsize]);

testsuite/ico/ref/out.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ Reading ../oiio-images/ico/oiio.ico
4545
oiio:BitsPerSample: 8
4646
Comparing "../oiio-images/ico/oiio.ico" and "oiio.ico"
4747
PASS
48+
iconvert ERROR: Unsupported image color depth, probably corrupt file

testsuite/ico/run.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@
44
# SPDX-License-Identifier: Apache-2.0
55
# https://github.com/AcademySoftwareFoundation/OpenImageIO
66

7-
command = rw_command (OIIO_TESTSUITE_IMAGEDIR, "oiio.ico")
7+
failureok = 1
8+
redirect = ' >> out.txt 2>&1 '
9+
10+
command += rw_command (OIIO_TESTSUITE_IMAGEDIR, "oiio.ico")
11+
command += run_app (oiio_app("iconvert") + " src/bad1.ico out.tif")
12+

testsuite/ico/src/bad1.ico

69 Bytes
Binary file not shown.

testsuite/rla/ref/out.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,5 +319,8 @@ Full command line was:
319319
oiiotool ERROR: read : "src/crash-3951.rla": Read error: couldn't read RLE data span
320320
Full command line was:
321321
> oiiotool src/crash-3951.rla -o crash4.exr
322+
oiiotool ERROR: read : "src/crash-1.rla": Probably corrupt file (buffer overrun avoided)
323+
Full command line was:
324+
> oiiotool src/crash-1.rla -o crash5.exr
322325
Comparing "rlacrop.rla" and "ref/rlacrop.rla"
323326
PASS

testsuite/rla/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
command += oiiotool(OIIO_TESTSUITE_IMAGEDIR + "/crash2.rla -o crash2.exr", failureok = True)
2323
command += oiiotool("src/crash-1629.rla -o crash3.exr", failureok = True)
2424
command += oiiotool("src/crash-3951.rla -o crash4.exr", failureok = True)
25+
command += oiiotool("src/crash-1.rla -o crash5.exr", failureok = True)
2526

2627
outputs = [ "rlacrop.rla", 'out.txt' ]

testsuite/rla/src/crash-1.rla

772 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)