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