mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-20 01:25:43 +00:00
[C++] fix bounds checking on integer parsing (#4250)
* fix bounds checking on integer parsing the previous code was allowing 255 for int8_t, similar for int16_t and int32_t, and even negative values for unsignd types. this patch fixes bounds checking for 8-bit, 16-bit and 32-bit types. testing for both acceptable values and unacceptable values at the boundaries are also improved. bounds checking on 64-bit types isn't addressed by this patch. * fix 'unary minus operator applied to unsigned type, result still unsigned' * fix & placement
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
b90d4e049d
commit
a07f0d428d
@@ -530,7 +530,7 @@ class Parser : public ParserState {
|
||||
// of the schema provided. Returns non-empty error on any problems.
|
||||
std::string ConformTo(const Parser &base);
|
||||
|
||||
FLATBUFFERS_CHECKED_ERROR CheckBitsFit(int64_t val, size_t bits);
|
||||
FLATBUFFERS_CHECKED_ERROR CheckInRange(int64_t val, int64_t min, int64_t max);
|
||||
|
||||
private:
|
||||
FLATBUFFERS_CHECKED_ERROR Error(const std::string &msg);
|
||||
|
||||
Reference in New Issue
Block a user