Private
Public Access
2
0

stability: replace strcpy with strncpy to avoid potential overflows

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
This commit is contained in:
Alex Tereschenko
2017-05-13 18:08:52 +02:00
parent 0654183b9a
commit 9545a2e320

View File

@@ -249,9 +249,11 @@ run_interactive_mode()
if (strcmp(command, "q") == 0)
return;
char* str = strtok(command, " ");
int len = 0;
while (str != NULL) {
arg = malloc(strlen(str) + 1);
argv[argc++] = strcpy(arg, str);
len = strlen(str) + 1;
arg = malloc(len);
argv[argc++] = strncpy(arg, str, len);
str = strtok(NULL, " ");
}
process_command(argc, argv);