Skip to content

Commit 6bc118c

Browse files
authored
audit: add check for function and message length (#418)
1 parent a37e983 commit 6bc118c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

solidity/src/processor/ProcessorBase.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ abstract contract ProcessorBase is Ownable {
120120
bytes memory errorData;
121121
bool succeeded = true;
122122

123+
// Check that the number of messages matches the number of functions
124+
// for protection against mismatched inputs
125+
if (nonAtomicSubroutine.functions.length != messages.length) {
126+
revert("Number of messages does not match number of functions");
127+
}
128+
123129
// Execute each function until one fails
124130
for (uint8 i = 0; i < nonAtomicSubroutine.functions.length; i++) {
125131
address targetContract = nonAtomicSubroutine.functions[i].contractAddress;
@@ -174,6 +180,12 @@ abstract contract ProcessorBase is Ownable {
174180
revert ProcessorErrors.UnauthorizedAccess();
175181
}
176182

183+
// Check that the number of messages matches the number of functions
184+
// for protection against mismatched inputs
185+
if (atomicSubroutine.functions.length != messages.length) {
186+
revert("Number of messages does not match number of functions");
187+
}
188+
177189
for (uint8 i = 0; i < atomicSubroutine.functions.length; i++) {
178190
address targetContract = atomicSubroutine.functions[i].contractAddress;
179191
// Check contract existence, need to do this check because in EVM

0 commit comments

Comments
 (0)