1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

Merge pull request #2215 from acqn/VariadicCallCheck

[cc65] Added check for total arguments size for variadic functions
This commit is contained in:
Bob Andrews 2023-10-08 13:13:08 +02:00 committed by GitHub
commit ee6118f235
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -1035,6 +1035,10 @@ static void FunctionCall (ExprDesc* Expr)
/* Parse the argument list and pass them to the called function */
ArgSize = FunctionArgList (Func, IsFastcall, Expr);
if (ArgSize > 0xFF && (Func->Flags & FD_VARIADIC) != 0) {
Error ("Total size of all arguments passed to a variadic function cannot exceed 255 bytes");
}
/* We need the closing paren here */
ConsumeRParen ();

13
test/err/bug2144.c Normal file
View File

@ -0,0 +1,13 @@
/* Bug #2144 - Maximum parameter size is not checked for variadic functions */
void a(...) {}
void b()
{
/* Argument size > 255 */
a(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L);
}