From 001f262590494da215ebd160debbd49dec7293cf Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Wed, 17 Dec 2014 21:28:27 +0300 Subject: [PATCH] Limiting maximum command line arguments by CONFIG_JERRY_MAX_COMMAND_LINE_ARGS configuration option. --- src/config.h | 5 +++++ src/main.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/config.h b/src/config.h index 299a0bd6d..644000d48 100644 --- a/src/config.h +++ b/src/config.h @@ -154,4 +154,9 @@ // #define CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN #endif /* CONFIG_ECMA_COMPACT_PROFILE */ +/** + * Maximum number of arguments in the engine's command line (i.e. maximum argc value) + */ +#define CONFIG_JERRY_MAX_COMMAND_LINE_ARGS 64 + #endif /* !CONFIG_H */ diff --git a/src/main.c b/src/main.c index 68c104169..0ea227bc5 100644 --- a/src/main.c +++ b/src/main.c @@ -138,7 +138,12 @@ int main (int argc __unused, char **argv __unused) { - const char *file_names[argc]; + if (argc > CONFIG_JERRY_MAX_COMMAND_LINE_ARGS) + { + jerry_exit (ERR_OUT_OF_MEMORY); + } + + const char *file_names[CONFIG_JERRY_MAX_COMMAND_LINE_ARGS]; bool parse_only = false, show_opcodes = false; bool print_mem_stats = false; int i;