From 882b76eb5e918d75d700b55098fd7af640610ad5 Mon Sep 17 00:00:00 2001 From: BoB13-Matter Date: Tue, 12 Nov 2024 01:27:04 +0900 Subject: [PATCH] Fix argument count handling in Command::InitArguments to prevent integer overflow (#36414) * Fix unsigned overflow in Command::InitArguments with zero args * Update format --- examples/chip-tool/commands/common/Command.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/chip-tool/commands/common/Command.cpp b/examples/chip-tool/commands/common/Command.cpp index 82e9eedc461dd5..91a65db789d976 100644 --- a/examples/chip-tool/commands/common/Command.cpp +++ b/examples/chip-tool/commands/common/Command.cpp @@ -55,6 +55,10 @@ bool Command::InitArguments(int argc, char ** argv) { optionalArgsCount++; } + else if (argvExtraArgsCount == 0) + { + mandatoryArgsCount++; + } else { mandatoryArgsCount++;