Fix segfault on 'rem <verylongline>'

This commit is contained in:
Philippe Teuwen 2021-09-04 02:57:16 +02:00
commit 8ce20320b2

View file

@ -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);