Skip to content

Commit 6c90915

Browse files
authored
Merge pull request wolfSSL#202 from miyazakh/f-635_out_of_bounds
f-635: fix out of bunds writes for `argv`
2 parents 9ac6097 + 6cc213d commit 6c90915

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)