From 29b807d660ee9564ddb9c76888d021fec5e26b21 Mon Sep 17 00:00:00 2001 From: Arseny Smirnov Date: Wed, 31 Jul 2019 13:45:32 +0300 Subject: [PATCH] TRY_END_PARSE_FLAGS_GENERIC GitOrigin-RevId: c68a348c7466daa7ab3b6b93217585a18458885d --- td/telegram/files/FileData.hpp | 2 +- tdutils/td/utils/tl_helpers.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/td/telegram/files/FileData.hpp b/td/telegram/files/FileData.hpp index e3be9c76..f2ff55be 100644 --- a/td/telegram/files/FileData.hpp +++ b/td/telegram/files/FileData.hpp @@ -80,7 +80,7 @@ void FileData::parse(ParserT &parser, bool register_file_sources) { PARSE_FLAG(encryption_key_is_secure); PARSE_FLAG(has_sources); PARSE_FLAG(has_version); - END_PARSE_FLAGS_GENERIC(); + TRY_END_PARSE_FLAGS_GENERIC(); int32 version = 0; if (has_version) { diff --git a/tdutils/td/utils/tl_helpers.h b/tdutils/td/utils/tl_helpers.h index f2dfeae0..33a5905c 100644 --- a/tdutils/td/utils/tl_helpers.h +++ b/tdutils/td/utils/tl_helpers.h @@ -57,6 +57,15 @@ } \ while (false) +#define TRY_END_PARSE_FLAGS_GENERIC() \ + CHECK(bit_offset_parse < 31); \ + if ((flags_parse & ~((1 << bit_offset_parse) - 1)) != 0) { \ + parser.set_error("invalid flags"); \ + return; \ + } \ + } \ + while (false) + namespace td { template