From 622c2491b9836c966eb3a34ab3f9385683690e59 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 26 Apr 2023 00:48:12 -0700 Subject: [PATCH] Debugger: Reject traces with negative trace amounts (fixes #2900) --- src/debugger/cli-debugger.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/debugger/cli-debugger.c b/src/debugger/cli-debugger.c index 12cd7af18..3dce8e255 100644 --- a/src/debugger/cli-debugger.c +++ b/src/debugger/cli-debugger.c @@ -809,10 +809,14 @@ static void _listWatchpoints(struct CLIDebugger* debugger, struct CLIDebugVector } static void _trace(struct CLIDebugger* debugger, struct CLIDebugVector* dv) { - if (!dv || dv->type != CLIDV_INT_TYPE) { + if (!dv) { debugger->backend->printf(debugger->backend, "%s\n", ERROR_MISSING_ARGS); return; } + if (dv->type != CLIDV_INT_TYPE || dv->intValue < 0) { + debugger->backend->printf(debugger->backend, "%s\n", ERROR_INVALID_ARGS); + return; + } debugger->traceRemaining = dv->intValue; if (debugger->traceVf) {