Skip to content

Commit

Permalink
check for integer overflow in color_conversion_fuzzer (should fix Clu…
Browse files Browse the repository at this point in the history
…sterfuzz issue 59814). Bug is in fuzzer code, not in library.
  • Loading branch information
farindk committed Oct 12, 2023
1 parent a26bcb0 commit 94e5a84
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fuzzing/color_conversion_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ static bool read_plane(BitstreamRange* range,
if (width <= 0 || height <= 0) {
return false;
}
if (!range->prepare_read(static_cast<uint64_t>(width) * height)) {
if (std::numeric_limits<size_t>::max()/width/height == 0) {
return false;
}
if (!range->prepare_read(static_cast<size_t>(width) * height)) {
return false;
}
if (!image->add_plane(channel, width, height, bit_depth)) {
Expand All @@ -87,7 +90,10 @@ static bool read_plane_interleaved(BitstreamRange* range,
if (width <= 0 || height <= 0) {
return false;
}
if (!range->prepare_read(static_cast<uint64_t>(width) * height * comps)) {
if (std::numeric_limits<size_t>::max()/width/height/comps == 0) {
return false;
}
if (!range->prepare_read(static_cast<size_t>(width) * height * comps)) {
return false;
}
if (!image->add_plane(channel, width, height, bit_depth)) {
Expand Down

0 comments on commit 94e5a84

Please sign in to comment.