diff --git a/client/deps/cliparser/cliparser.c b/client/deps/cliparser/cliparser.c index 2a5804550..cae61a9e8 100644 --- a/client/deps/cliparser/cliparser.c +++ b/client/deps/cliparser/cliparser.c @@ -149,6 +149,7 @@ int CLIParserParseStringEx(CLIParserContext *ctx, const char *str, void *vargtab int len = strlen(str); memset(ctx->buf, 0x00, ARRAYLEN(ctx->buf)); char *bufptr = ctx->buf; + char *bufptrend = ctx->buf + ARRAYLEN(ctx->buf) - 1; char *spaceptr = NULL; enum ParserState state = PS_FIRST; @@ -198,6 +199,11 @@ int CLIParserParseStringEx(CLIParserContext *ctx, const char *str, void *vargtab bufptr++; break; } + if (bufptr > bufptrend) { + PrintAndLogEx(ERR, "ERROR: Line too long\n"); + fflush(stdout); + return 2; + } } return CLIParserParseArg(ctx, argc, argv, vargtable, vargtableLen, allowEmptyExec);