Skip to content

Commit 6819d64

Browse files
committed
feat: Added check_open for PNG, JPEG, and EXR readers
Signed-off-by: Dharshan Vishwanatha <dharshanv1999@gmail.com>
1 parent fe9f7f8 commit 6819d64

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/jpeg.imageio/jpeginput.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ JpgInput::open(const std::string& name, ImageSpec& newspec)
253253
m_spec = ImageSpec(m_cinfo.output_width, m_cinfo.output_height, nchannels,
254254
TypeDesc::UINT8);
255255

256+
if (!check_open(m_spec, { 0, 1 << 16, 0, 1 << 16, 0, 1, 0, 3 }))
257+
return false;
258+
256259
// Assume JPEG is in sRGB unless the Exif or XMP tags say otherwise.
257260
m_spec.attribute("oiio:ColorSpace", "sRGB");
258261

src/openexr.imageio/exrinput.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,9 @@ OpenEXRInput::seek_subimage(int subimage, int miplevel)
10241024
m_miplevel = miplevel;
10251025
m_spec = part.spec;
10261026

1027+
if (!check_open(m_spec, { 0, 1 << 30, 0, 1 << 30, 0, 1 << 16, 0, 1 << 16 }))
1028+
return false;
1029+
10271030
if (miplevel == 0 && part.levelmode == Imf::ONE_LEVEL) {
10281031
return true;
10291032
}

src/png.imageio/pnginput.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ PNGInput::open(const std::string& name, ImageSpec& newspec)
162162
bool ok = PNG_pvt::read_info(m_png, m_info, m_bit_depth, m_color_type,
163163
m_interlace_type, m_bg, m_spec,
164164
m_keep_unassociated_alpha);
165-
if (!ok || m_err) {
165+
if (!ok || m_err
166+
|| check_open(m_spec, { 0, 1 << 30, 0, 1 << 30, 0, 1, 0, 4 })) {
166167
close();
167168
return false;
168169
}

0 commit comments

Comments
 (0)