Skip to content

Commit 3e51fb2

Browse files
Backport fixes for CVE-2025-64181 etc. in OpenEXRCore
1 parent 4875fcc commit 3e51fb2

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

pxr/imaging/plugin/hioOpenEXR/OpenEXR/OpenEXRCore/chunk.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,16 @@ exr_read_tile_chunk_info (
12921292
return pctxt->report_error (
12931293
pctxt, EXR_ERR_INVALID_ARGUMENT, "Invalid packed size of 0");
12941294

1295+
if (part->comp_type == EXR_COMPRESSION_NONE &&
1296+
cinfo->packed_size != cinfo->unpacked_size)
1297+
{
1298+
return pctxt->print_error (
1299+
pctxt,
1300+
EXR_ERR_BAD_CHUNK_LEADER,
1301+
"Mismatch between unpacked and packed size with uncompressed data: packed is %" PRIu64 "; unpacked is %" PRIu64,
1302+
cinfo->packed_size, cinfo->unpacked_size);
1303+
}
1304+
12951305
return EXR_ERR_SUCCESS;
12961306
}
12971307

@@ -1350,11 +1360,15 @@ exr_read_chunk (
13501360
rv = pctxt->do_read (
13511361
pctxt, packed_data, toread, &dataoffset, &nread, rmode);
13521362

1353-
if (rmode == EXR_ALLOW_SHORT_READ && nread < (int64_t) toread)
1363+
if (rmode == EXR_ALLOW_SHORT_READ &&
1364+
nread >= 0 &&
1365+
nread < (int64_t) toread)
1366+
{
13541367
memset (
13551368
((uint8_t*) packed_data) + nread,
1356-
0,
1357-
toread - (uint64_t) (nread));
1369+
0,
1370+
(size_t)(toread - (uint64_t)nread));
1371+
}
13581372
}
13591373
else
13601374
rv = EXR_ERR_SUCCESS;

pxr/imaging/plugin/hioOpenEXR/OpenEXR/OpenEXRCore/internal_util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ compute_sampled_height (int height, int y_sampling, int start_y)
3131
else
3232
start = start_y;
3333
end = start_y + height - 1;
34-
end -= (end < 0) ? (-end % y_sampling) : (end % y_sampling);
34+
end -= (end < 0 ? -end : end) % y_sampling;
3535

3636
if (start > end)
37-
nlines = 0;
37+
nlines = start == start_y ? 1 : 0;
3838
else
3939
nlines = (end - start) / y_sampling + 1;
4040
}

pxr/imaging/plugin/hioOpenEXR/OpenEXR/OpenEXRCore/parse_header.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2293,7 +2293,9 @@ internal_exr_compute_chunk_offset_size (struct _internal_exr_part* curpart)
22932293

22942294
w = (uint64_t) (((int64_t) dw.max.x) - ((int64_t) dw.min.x) + 1);
22952295

2296-
if (curpart->tiles)
2296+
if (curpart->storage_mode != EXR_STORAGE_SCANLINE &&
2297+
curpart->storage_mode != EXR_STORAGE_DEEP_SCANLINE &&
2298+
curpart->tiles)
22972299
{
22982300
const exr_attr_tiledesc_t* tiledesc = curpart->tiles->tiledesc;
22992301
int64_t tilecount = 0;

0 commit comments

Comments
 (0)