Skip to content

Commit 6cc213d

Browse files
committed
fix f-635: out of bunds writes
1 parent 9ac6097 commit 6cc213d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/clu_main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,16 @@ int clu_entry(const void* argument)
401401
}
402402
}
403403

404+
if (argc > MAX_COMMAND_ARGS) {
405+
WOLFCLU_LOG(WOLFCLU_L0, "Too many arguments (max %d)", MAX_COMMAND_ARGS);
406+
return -1;
407+
}
408+
404409
i = 0;
405410
token = strtok(command, " ");
406411

407412
/* split the command string to correspond to separate argv[i] */
408-
while (token != NULL && i <= MAX_COMMAND_ARGS) {
413+
while (token != NULL && i < argc) {
409414
argv[i] = XMALLOC(XSTRLEN(token)+1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
410415
XMEMSET(argv[i], 0, XSTRLEN(token)+1);
411416
XSTRNCPY(argv[i], token, XSTRLEN(token));

0 commit comments

Comments
 (0)