stability: replace strcpy with strncpy to avoid potential overflows
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
This commit is contained in:
@@ -249,9 +249,11 @@ run_interactive_mode()
|
|||||||
if (strcmp(command, "q") == 0)
|
if (strcmp(command, "q") == 0)
|
||||||
return;
|
return;
|
||||||
char* str = strtok(command, " ");
|
char* str = strtok(command, " ");
|
||||||
|
int len = 0;
|
||||||
while (str != NULL) {
|
while (str != NULL) {
|
||||||
arg = malloc(strlen(str) + 1);
|
len = strlen(str) + 1;
|
||||||
argv[argc++] = strcpy(arg, str);
|
arg = malloc(len);
|
||||||
|
argv[argc++] = strncpy(arg, str, len);
|
||||||
str = strtok(NULL, " ");
|
str = strtok(NULL, " ");
|
||||||
}
|
}
|
||||||
process_command(argc, argv);
|
process_command(argc, argv);
|
||||||
|
|||||||
Reference in New Issue
Block a user