#7500 buffer overflow: encodeMultiChar lib/mathlib.cpp:343. Improve errors handling
This commit is contained in:
parent
7453b641bd
commit
4f77a2b044
|
@ -356,6 +356,8 @@ MathLib::bigint MathLib::characterLiteralToLongNumber(const std::string& str)
|
|||
// is implementation-defined.
|
||||
// clang and gcc seem to use the following encoding: 'AB' as (('A' << 8) | 'B')
|
||||
const std::string& normStr = normalizeCharacterLiteral(str);
|
||||
if (normStr.empty())
|
||||
throw InternalError(0, "Internal Error. MathLib::characterLiteralToLongNumber: Unhandled char constant '" + str + "'.");
|
||||
return encodeMultiChar(normStr);
|
||||
}
|
||||
|
||||
|
|
|
@ -301,6 +301,7 @@ private:
|
|||
ASSERT_EQUALS(0, MathLib::characterLiteralToLongNumber(std::string("")));
|
||||
ASSERT_EQUALS(32, MathLib::characterLiteralToLongNumber(std::string(" ")));
|
||||
ASSERT_EQUALS(538976288, MathLib::characterLiteralToLongNumber(std::string(" ")));
|
||||
ASSERT_THROW(MathLib::characterLiteralToLongNumber(std::string("\\u")), InternalError);
|
||||
}
|
||||
|
||||
ASSERT_EQUALS(-8552249625308161526, MathLib::toLongNumber("0x89504e470d0a1a0a"));
|
||||
|
|
Loading…
Reference in New Issue