Skip to content

Commit

Permalink
Fix integer overflow in in cv::BmpDecoder::readHeader
Browse files Browse the repository at this point in the history
Bug: oss-fuzz:371546812
  • Loading branch information
vrabaud committed Jan 3, 2025
1 parent 5e1eed5 commit 845616d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/imgcodecs/src/grfmt_bmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ bool BmpDecoder::readHeader()
// in 32 bit case alpha channel is used - so require CV_8UC4 type
m_type = iscolor ? ((m_bpp == 32 && m_rle_code != BMP_RGB) ? CV_8UC4 : CV_8UC3 ) : CV_8UC1;
m_origin = m_height > 0 ? ORIGIN_BL : ORIGIN_TL;
m_height = std::abs(m_height);
if ( m_height == std::numeric_limits<int>::min() ) {
// abs(std::numeric_limits<int>::min()) is undefined behavior.
result = false;
} else {
m_height = std::abs(m_height);
}

if( !result )
{
Expand Down

0 comments on commit 845616d

Please sign in to comment.