From 6ac6111f5f3bc18360c5b80bf1ade95b2a06f2c8 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Wed, 2 Mar 2016 08:49:50 -0500 Subject: cleanup --- src/lib/common.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/lib') 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) { // check if this is a firejail executable char *comm = pid_proc_comm(newpid); if (comm) { - // remove \n - char *ptr = strchr(comm, '\n'); - if (ptr) - *ptr = '\0'; if (strcmp(comm, "firejail")) { free(comm); continue; @@ -150,6 +146,11 @@ char *pid_proc_comm(const pid_t pid) { buffer[len] = '\0'; close(fd); + // remove \n + char *ptr = strchr(buffer, '\n'); + if (ptr) + *ptr = '\0'; + // return a malloc copy of the command line char *rv = strdup((char *) buffer); if (strlen(rv) == 0) { -- cgit v1.2.3-54-g00ecf