Check the values of moduleConfigurationCount and keymapCount
This commit is contained in:
@@ -27,6 +27,9 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
|||||||
uint16_t keymapCount;
|
uint16_t keymapCount;
|
||||||
|
|
||||||
(void)dataModelVersion;
|
(void)dataModelVersion;
|
||||||
|
if (moduleConfigurationCount > 255) {
|
||||||
|
return ParserError_InvalidModuleConfigurationCount;
|
||||||
|
}
|
||||||
for (uint8_t moduleConfigurationIdx = 0; moduleConfigurationIdx < moduleConfigurationCount; moduleConfigurationIdx++) {
|
for (uint8_t moduleConfigurationIdx = 0; moduleConfigurationIdx < moduleConfigurationCount; moduleConfigurationIdx++) {
|
||||||
errorCode = parseModuleConfiguration(buffer);
|
errorCode = parseModuleConfiguration(buffer);
|
||||||
if (errorCode != ParserError_Success) {
|
if (errorCode != ParserError_Success) {
|
||||||
@@ -41,6 +44,9 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
keymapCount = readCompactLength(buffer);
|
keymapCount = readCompactLength(buffer);
|
||||||
|
if (keymapCount > 255) {
|
||||||
|
return ParserError_InvalidKeymapCount;
|
||||||
|
}
|
||||||
for (uint8_t keymapIdx = 0; keymapIdx < keymapCount; keymapIdx++) {
|
for (uint8_t keymapIdx = 0; keymapIdx < keymapCount; keymapIdx++) {
|
||||||
errorCode = ParseKeymap(buffer, keymapIdx, keymapCount);
|
errorCode = ParseKeymap(buffer, keymapIdx, keymapCount);
|
||||||
if (errorCode != ParserError_Success) {
|
if (errorCode != ParserError_Success) {
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
ParserError_InvalidActionCount,
|
ParserError_InvalidActionCount,
|
||||||
ParserError_InvalidSerializedMacroActionType,
|
ParserError_InvalidSerializedMacroActionType,
|
||||||
ParserError_InvalidSerializedSwitchKeymapAction,
|
ParserError_InvalidSerializedSwitchKeymapAction,
|
||||||
|
ParserError_InvalidModuleConfigurationCount,
|
||||||
|
ParserError_InvalidKeymapCount,
|
||||||
} parser_error_t;
|
} parser_error_t;
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|||||||
Reference in New Issue
Block a user