Origin: upstream, https://github.com/weidai11/cryptopp/commit/
07dbcc3d9644b18e05c1776db2a57fe04d780965
Bug: https://github.com/weidai11/cryptopp/issues/414
Last-Update: 2017-06-05
The improved validation and excpetion clears the Address Sanitizer and
Undefined Behavior Sanitizer findings
Gbp-Pq: Name zinflate-564.diff
break;\r
}\r
case DISTANCE_BITS:\r
+ if (m_distance >= sizeof(distanceExtraBits)/sizeof(distanceExtraBits[0]))\r
+ throw BadDistanceErr();\r
bits = distanceExtraBits[m_distance];\r
if (!m_reader.FillBuffer(bits))\r
{\r
m_nextDecode = DISTANCE_BITS;\r
break;\r
}\r
+ if (m_distance >= sizeof(distanceStarts)/sizeof(distanceStarts[0]))\r
+ throw BadDistanceErr();\r
m_distance = m_reader.GetBits(bits) + distanceStarts[m_distance];\r
OutputPast(m_literal, m_distance);\r
}\r
};\r
class UnexpectedEndErr : public Err {public: UnexpectedEndErr() : Err(INVALID_DATA_FORMAT, "Inflator: unexpected end of compressed block") {}};\r
class BadBlockErr : public Err {public: BadBlockErr() : Err(INVALID_DATA_FORMAT, "Inflator: error in compressed block") {}};\r
+ class BadDistanceErr : public Err {public: BadDistanceErr() : Err(INVALID_DATA_FORMAT, "Inflator: error in bit distance") {}};\r
\r
//! \brief RFC 1951 Decompressor\r
//! \param attachment the filter's attached transformation\r