diff --git a/right/src/config_parser/parse_config.c b/right/src/config_parser/parse_config.c index c9f0a58..5457931 100644 --- a/right/src/config_parser/parse_config.c +++ b/right/src/config_parser/parse_config.c @@ -3,6 +3,7 @@ #include "parse_macro.h" #include "keymaps.h" #include "config_globals.h" +#include "macros.h" static parser_error_t parseModuleConfiguration(config_buffer_t *buffer) { @@ -37,6 +38,9 @@ parser_error_t ParseConfig(config_buffer_t *buffer) } } macroCount = readCompactLength(buffer); + if (macroCount > MAX_MACRO_NUM) { + return ParserError_InvalidMacroCount; + } for (uint16_t macroIdx = 0; macroIdx < macroCount; macroIdx++) { errorCode = ParseMacro(buffer, macroIdx); if (errorCode != ParserError_Success) { diff --git a/right/src/config_parser/parse_config.h b/right/src/config_parser/parse_config.h index 1e901c1..850e42f 100644 --- a/right/src/config_parser/parse_config.h +++ b/right/src/config_parser/parse_config.h @@ -20,6 +20,7 @@ ParserError_InvalidModuleConfigurationCount, ParserError_InvalidKeymapCount, ParserError_InvalidAbbreviationLen, + ParserError_InvalidMacroCount, } parser_error_t; // Functions: