aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kjellerstedt <pkj@axis.com>2020-11-21 17:30:33 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-12-16 16:50:26 +0000
commit6fd57da7b1de1a2b6cf530e336d58bb5f8bdd015 (patch)
tree70bf14ea09921039ea66386d9dd56843637e5b9c
parent2ae4513c340d9d284169921d6a160de4ef81d581 (diff)
downloadpseudo-6fd57da7b1de1a2b6cf530e336d58bb5f8bdd015.tar.gz
pseudo-6fd57da7b1de1a2b6cf530e336d58bb5f8bdd015.tar.bz2
pseudo-6fd57da7b1de1a2b6cf530e336d58bb5f8bdd015.zip
pseudo_client: Simplify pseudo_client_ignore_path_chroot()
This also plugs a memory leak by making sure env is freed. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--pseudo_client.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/pseudo_client.c b/pseudo_client.c
index 5549986..3c49644 100644
--- a/pseudo_client.c
+++ b/pseudo_client.c
@@ -1538,23 +1538,22 @@ int pseudo_client_ignore_path_chroot(const char *path, int ignore_chroot) {
if (!env)
return 0;
+ int ret = 0;
char *p = env;
- while (*p) {
+ while (p) {
char *next = strchr(p, ',');
- if (!next)
- next = strchr(p, '\0');
- if ((next - p) && !strncmp(path, p, next - p)) {
- pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, "ignoring path: '%s'\n", path);
- return 1;
- }
- if (next && *next != '\0')
- p = next+1;
- else
+ if (next)
+ *next++ = '\0';
+ if (*p && !strncmp(path, p, strlen(p))) {
+ pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, "ignoring path: '%s'\n", path);
+ ret = 1;
break;
+ }
+ p = next;
}
free(env);
- return 0;
+ return ret;
}
int pseudo_client_ignore_path(const char *path) {