aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-09-15 16:19:49 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-09-15 16:20:22 +0200
commit265e81a344defb05bd7d420d125cde169b8995af (patch)
treec0be861638f4e1e88b3f5e0d9aaf4e45bac33313
parentversion: bump (diff)
downloadwireguard-tools-265e81a344defb05bd7d420d125cde169b8995af.tar.xz
wireguard-tools-265e81a344defb05bd7d420d125cde169b8995af.zip
wg-quick: android: do not free iterated pointer
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--src/wg-quick/android.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/wg-quick/android.c b/src/wg-quick/android.c
index 2ad107e..326efa9 100644
--- a/src/wg-quick/android.c
+++ b/src/wg-quick/android.c
@@ -785,6 +785,7 @@ static uid_t *get_uid_list(const char *selected_applications)
static void set_users(unsigned int netid, const char *excluded_applications, const char *included_applications)
{
_cleanup_free_ uid_t *uids = NULL;
+ uid_t *uid;
unsigned int args_per_command = 0;
_cleanup_free_ char *ranges = NULL;
char range[22];
@@ -796,14 +797,14 @@ static void set_users(unsigned int netid, const char *excluded_applications, con
}
if (excluded_applications || !included_applications) {
- uids = get_uid_list(excluded_applications);
- for (start = 0; *uids; start = *uids + 1, ++uids) {
- if (start > *uids - 1)
+ uid = uids = get_uid_list(excluded_applications);
+ for (start = 0; *uid; start = *uid + 1, ++uid) {
+ if (start > *uid - 1)
continue;
- else if (start == *uids - 1)
+ else if (start == *uid - 1)
snprintf(range, sizeof(range), "%u", start);
else
- snprintf(range, sizeof(range), "%u-%u", start, *uids - 1);
+ snprintf(range, sizeof(range), "%u-%u", start, *uid - 1);
ranges = concat_and_free(ranges, " ", range);
if (++args_per_command % 18 == 0) {
cndc("network users add %u %s", netid, ranges);
@@ -816,8 +817,8 @@ static void set_users(unsigned int netid, const char *excluded_applications, con
ranges = concat_and_free(ranges, " ", range);
}
} else {
- for (uids = get_uid_list(included_applications); *uids; ++uids) {
- snprintf(range, sizeof(range), "%u", *uids);
+ for (uid = uids = get_uid_list(included_applications); *uid; ++uid) {
+ snprintf(range, sizeof(range), "%u", *uid);
ranges = concat_and_free(ranges, " ", range);
if (++args_per_command % 18 == 0) {
cndc("network users add %u %s", netid, ranges);