diff options
Diffstat (limited to 'src/lib/common.c')
-rw-r--r-- | src/lib/common.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib/common.c b/src/lib/common.c index f321c5a47..fd3ab7071 100644 --- a/src/lib/common.c +++ b/src/lib/common.c | |||
@@ -84,10 +84,6 @@ int name2pid(const char *name, pid_t *pid) { | |||
84 | // check if this is a firejail executable | 84 | // check if this is a firejail executable |
85 | char *comm = pid_proc_comm(newpid); | 85 | char *comm = pid_proc_comm(newpid); |
86 | if (comm) { | 86 | if (comm) { |
87 | // remove \n | ||
88 | char *ptr = strchr(comm, '\n'); | ||
89 | if (ptr) | ||
90 | *ptr = '\0'; | ||
91 | if (strcmp(comm, "firejail")) { | 87 | if (strcmp(comm, "firejail")) { |
92 | free(comm); | 88 | free(comm); |
93 | continue; | 89 | continue; |
@@ -150,6 +146,11 @@ char *pid_proc_comm(const pid_t pid) { | |||
150 | buffer[len] = '\0'; | 146 | buffer[len] = '\0'; |
151 | close(fd); | 147 | close(fd); |
152 | 148 | ||
149 | // remove \n | ||
150 | char *ptr = strchr(buffer, '\n'); | ||
151 | if (ptr) | ||
152 | *ptr = '\0'; | ||
153 | |||
153 | // return a malloc copy of the command line | 154 | // return a malloc copy of the command line |
154 | char *rv = strdup((char *) buffer); | 155 | char *rv = strdup((char *) buffer); |
155 | if (strlen(rv) == 0) { | 156 | if (strlen(rv) == 0) { |