diff --git a/right/src/config_parser/parse_config.c b/right/src/config_parser/parse_config.c index 4ee9f71..df1f87c 100644 --- a/right/src/config_parser/parse_config.c +++ b/right/src/config_parser/parse_config.c @@ -27,6 +27,9 @@ parser_error_t ParseConfig(config_buffer_t *buffer) uint16_t keymapCount; (void)dataModelVersion; + if (moduleConfigurationCount > 255) { + return ParserError_InvalidModuleConfigurationCount; + } for (uint8_t moduleConfigurationIdx = 0; moduleConfigurationIdx < moduleConfigurationCount; moduleConfigurationIdx++) { errorCode = parseModuleConfiguration(buffer); if (errorCode != ParserError_Success) { @@ -41,6 +44,9 @@ parser_error_t ParseConfig(config_buffer_t *buffer) } } keymapCount = readCompactLength(buffer); + if (keymapCount > 255) { + return ParserError_InvalidKeymapCount; + } for (uint8_t keymapIdx = 0; keymapIdx < keymapCount; keymapIdx++) { errorCode = ParseKeymap(buffer, keymapIdx, keymapCount); if (errorCode != ParserError_Success) { diff --git a/right/src/config_parser/parse_config.h b/right/src/config_parser/parse_config.h index b4d203a..2bc44df 100644 --- a/right/src/config_parser/parse_config.h +++ b/right/src/config_parser/parse_config.h @@ -17,6 +17,8 @@ ParserError_InvalidActionCount, ParserError_InvalidSerializedMacroActionType, ParserError_InvalidSerializedSwitchKeymapAction, + ParserError_InvalidModuleConfigurationCount, + ParserError_InvalidKeymapCount, } parser_error_t; // Functions: