From c60682b6ba266c6c5f9f10f30b0d87880e29d9b3 Mon Sep 17 00:00:00 2001 From: Roman-Koshelev Date: Sun, 11 Apr 2021 14:29:23 +0300 Subject: [PATCH] message_reader::init() Rewritten check MsgType We will strengthen the check, and also detect an invalid message for as few characters as possible --- include/hffix.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/hffix.hpp b/include/hffix.hpp index a283b30..f31e677 100644 --- a/include/hffix.hpp +++ b/include/hffix.hpp @@ -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;