blob: a657a27f285a1ff2e016ad3ff400e1aceaaeb7f0 [file] [log] [blame]
Andrew Geissler706d5aa2021-02-12 15:55:30 -06001From a1d61d68777373a50ae23b9dd83b428abe2f748d Mon Sep 17 00:00:00 2001
2From: Peter Kjellerstedt <pkj@axis.com>
3Date: Sat, 21 Nov 2020 17:30:33 +0100
4Subject: [PATCH] pseudo_client: Simplify pseudo_client_ignore_path_chroot()
5
6This also plugs a memory leak by making sure env is freed.
7
8Change-Id: Ia8635fd2c6b1e85919e4743713a85e0b52c28fac
9---
10 pseudo_client.c | 21 ++++++++++-----------
11 1 file changed, 10 insertions(+), 11 deletions(-)
12
13diff --git a/pseudo_client.c b/pseudo_client.c
14index a8bc3dc..7dc0345 100644
15--- a/pseudo_client.c
16+++ b/pseudo_client.c
17@@ -1538,23 +1538,22 @@ int pseudo_client_ignore_path_chroot(const char *path, int ignore_chroot) {
18 if (!env)
19 return 0;
20
21+ int ret = 0;
22 char *p = env;
23- while (*p) {
24+ while (p) {
25 char *next = strchr(p, ',');
26- if (!next)
27- next = strchr(p, '\0');
28- if ((next - p) && !strncmp(path, p, next - p)) {
29- pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, "ignoring path: '%s'\n", path);
30- return 1;
31- }
32- if (next && *next != '\0')
33- p = next+1;
34- else
35+ if (next)
36+ *next++ = '\0';
37+ if (*p && !strncmp(path, p, strlen(p))) {
38+ pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, "ignoring path: '%s'\n", path);
39+ ret = 1;
40 break;
41+ }
42+ p = next;
43 }
44 free(env);
45
46- return 0;
47+ return ret;
48 }
49
50 int pseudo_client_ignore_path(const char *path) {