Skip to content

Commit 4ca89db

Browse files
committed
imgproc(hdr): fix bounds check in HdrDecoder::checkSignature()
1 parent 30373d2 commit 4ca89db

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

modules/imgcodecs/src/grfmt_hdr.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,14 @@ bool HdrDecoder::readData(Mat& _img)
101101

102102
bool HdrDecoder::checkSignature( const String& signature ) const
103103
{
104-
if(signature.size() >= m_signature.size() &&
105-
(!memcmp(signature.c_str(), m_signature.c_str(), m_signature.size()) ||
106-
!memcmp(signature.c_str(), m_signature_alt.c_str(), m_signature_alt.size())))
107-
return true;
104+
if (signature.size() >= m_signature.size() &&
105+
0 == memcmp(signature.c_str(), m_signature.c_str(), m_signature.size())
106+
)
107+
return true;
108+
if (signature.size() >= m_signature_alt.size() &&
109+
0 == memcmp(signature.c_str(), m_signature_alt.c_str(), m_signature_alt.size())
110+
)
111+
return true;
108112
return false;
109113
}
110114

0 commit comments

Comments
 (0)