Skip to content

Commit

Permalink
message_reader::init() Rewritten check MsgType
Browse files Browse the repository at this point in the history
We will strengthen the check, and also detect an
invalid message for as few characters as possible
  • Loading branch information
Roman-Koshelev committed Apr 11, 2021
1 parent 154d2c3 commit c60682b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions include/hffix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2286,12 +2286,12 @@ class message_reader {
bodylength += tmp - '0'; // we know that 0 <= (*b - '0') <= 9, so rvalue will be positive.
}

if (b + 3 >= buffer_end_) return;

if (*b != '3' || b[1] != '5') { // next field must be tag 35 MsgType
invalid();
return;
}
if (b >= buffer_end_) return;
if (*b != '3') return invalid();
if (b + 1 >= buffer_end_) return;
if (b[1] != '5') return invalid();
if (b + 2 >= buffer_end_) return;
if (b[2] != '=') return invalid();

char const* checksum = b + bodylength;

Expand Down

0 comments on commit c60682b

Please sign in to comment.