]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
wg-quick: android: do not free iterated pointer
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 15 Sep 2020 14:19:49 +0000 (16:19 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 15 Sep 2020 14:20:22 +0000 (16:20 +0200)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
src/wg-quick/android.c

index 2ad107eb1fb60157e2fc935cbfabdae16fed9070..326efa9af49703c2ce0d5678c4819ec8cd5c129c 100644 (file)
@@ -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);