Skip to content

Commit 7c9ff30

Browse files
committed
Use strncpy instead of strlcpy to copy splashkill process name
In this particular use, the fact that strncpy doesn't guarantee a terminating '\0' when the string only just fits is actually an advantage, since the original string already has a '\0' that is not included in the passed size. Also, strlcpy is not available in glibc. It is available in uClibc and musl though.
1 parent cec6477 commit 7c9ff30

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

splashkill.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#define _BSD_SOURCE
2-
31
#include <stdio.h>
42
#include <stdlib.h>
53
#include <string.h>
@@ -61,7 +59,7 @@ int main(int argc, char **argv)
6159
execl(init_fn, "/init", NULL);
6260

6361
(void)argc;
64-
strlcpy(argv[0], process_name, strlen(argv[0]));
62+
strncpy(argv[0], process_name, strlen(argv[0]));
6563

6664
int res = waitForEnter();
6765
if (res)

0 commit comments

Comments
 (0)