diff options
author | 2018-08-26 08:15:34 -0400 | |
---|---|---|
committer | 2018-08-26 08:15:34 -0400 | |
commit | a6555dfa2dc9ad8dc2ea994f64ddd39c07b2d2fa (patch) | |
tree | 6ac2ca71d65fd2ce12aa6215ef56d87de9b606b6 /src/lib | |
parent | removed --ls, --get, --put (diff) | |
download | firejail-a6555dfa2dc9ad8dc2ea994f64ddd39c07b2d2fa.tar.gz firejail-a6555dfa2dc9ad8dc2ea994f64ddd39c07b2d2fa.tar.zst firejail-a6555dfa2dc9ad8dc2ea994f64ddd39c07b2d2fa.zip |
merge from mainline
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/common.c | 6 | ||||
-rw-r--r-- | src/lib/pid.c | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/common.c b/src/lib/common.c index fa988446b..d6dd43c4b 100644 --- a/src/lib/common.c +++ b/src/lib/common.c | |||
@@ -129,7 +129,7 @@ char *pid_proc_comm(const pid_t pid) { | |||
129 | // open /proc/pid/cmdline file | 129 | // open /proc/pid/cmdline file |
130 | char *fname; | 130 | char *fname; |
131 | int fd; | 131 | int fd; |
132 | if (asprintf(&fname, "/proc/%d//comm", pid) == -1) | 132 | if (asprintf(&fname, "/proc/%d/comm", pid) == -1) |
133 | return NULL; | 133 | return NULL; |
134 | if ((fd = open(fname, O_RDONLY)) < 0) { | 134 | if ((fd = open(fname, O_RDONLY)) < 0) { |
135 | free(fname); | 135 | free(fname); |
@@ -154,6 +154,8 @@ char *pid_proc_comm(const pid_t pid) { | |||
154 | 154 | ||
155 | // return a malloc copy of the command line | 155 | // return a malloc copy of the command line |
156 | char *rv = strdup(buffer); | 156 | char *rv = strdup(buffer); |
157 | if (!rv) | ||
158 | return NULL; | ||
157 | if (strlen(rv) == 0) { | 159 | if (strlen(rv) == 0) { |
158 | free(rv); | 160 | free(rv); |
159 | return NULL; | 161 | return NULL; |
@@ -192,6 +194,8 @@ char *pid_proc_cmdline(const pid_t pid) { | |||
192 | 194 | ||
193 | // return a malloc copy of the command line | 195 | // return a malloc copy of the command line |
194 | char *rv = strdup((char *) buffer); | 196 | char *rv = strdup((char *) buffer); |
197 | if (!rv) | ||
198 | return NULL; | ||
195 | if (strlen(rv) == 0) { | 199 | if (strlen(rv) == 0) { |
196 | free(rv); | 200 | free(rv); |
197 | return NULL; | 201 | return NULL; |
diff --git a/src/lib/pid.c b/src/lib/pid.c index 3c804716d..75576c787 100644 --- a/src/lib/pid.c +++ b/src/lib/pid.c | |||
@@ -149,7 +149,7 @@ uid_t pid_get_uid(pid_t pid) { | |||
149 | char buf[PIDS_BUFLEN]; | 149 | char buf[PIDS_BUFLEN]; |
150 | while (fgets(buf, PIDS_BUFLEN - 1, fp)) { | 150 | while (fgets(buf, PIDS_BUFLEN - 1, fp)) { |
151 | if (strncmp(buf, "Uid:", 4) == 0) { | 151 | if (strncmp(buf, "Uid:", 4) == 0) { |
152 | char *ptr = buf + 5; | 152 | char *ptr = buf + 4; |
153 | while (*ptr != '\0' && (*ptr == ' ' || *ptr == '\t')) { | 153 | while (*ptr != '\0' && (*ptr == ' ' || *ptr == '\t')) { |
154 | ptr++; | 154 | ptr++; |
155 | } | 155 | } |
@@ -398,7 +398,7 @@ void pid_read(pid_t mon_pid) { | |||
398 | pids[pid].parent = parent; | 398 | pids[pid].parent = parent; |
399 | } | 399 | } |
400 | else if (strncmp(buf, "Uid:", 4) == 0) { | 400 | else if (strncmp(buf, "Uid:", 4) == 0) { |
401 | char *ptr = buf + 5; | 401 | char *ptr = buf + 4; |
402 | while (*ptr != '\0' && (*ptr == ' ' || *ptr == '\t')) { | 402 | while (*ptr != '\0' && (*ptr == ' ' || *ptr == '\t')) { |
403 | ptr++; | 403 | ptr++; |
404 | } | 404 | } |