Skip to content

Commit 1aa88f0

Browse files
committed
Replace strcat with strncat
Bound the maximal length to the size of path(char[128]). Originally strcat is used due to laziness, which trusts the user having sanity not to overflow the buffer.
1 parent 4961436 commit 1aa88f0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ccnshell.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ int main(int argc, char **argv)
148148
int status;
149149
waitpid(pid, &status, 0);
150150
} else {
151-
execve(strcat(path, line), args, envp);
151+
execve(strncat(path, line, 127 - 9), args, envp);
152152
fprintf(stderr, "|| Failed to execute '%s': %s ||\n", line,
153153
strerror(errno));
154154
exit(EXIT_FAILURE); // What is the difference with _exit()?

0 commit comments

Comments
 (0)