Skip to content

Commit 265e81a

Browse files
committed
wg-quick: android: do not free iterated pointer
Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 7a321ce commit 265e81a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/wg-quick/android.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ static uid_t *get_uid_list(const char *selected_applications)
785785
static void set_users(unsigned int netid, const char *excluded_applications, const char *included_applications)
786786
{
787787
_cleanup_free_ uid_t *uids = NULL;
788+
uid_t *uid;
788789
unsigned int args_per_command = 0;
789790
_cleanup_free_ char *ranges = NULL;
790791
char range[22];
@@ -796,14 +797,14 @@ static void set_users(unsigned int netid, const char *excluded_applications, con
796797
}
797798

798799
if (excluded_applications || !included_applications) {
799-
uids = get_uid_list(excluded_applications);
800-
for (start = 0; *uids; start = *uids + 1, ++uids) {
801-
if (start > *uids - 1)
800+
uid = uids = get_uid_list(excluded_applications);
801+
for (start = 0; *uid; start = *uid + 1, ++uid) {
802+
if (start > *uid - 1)
802803
continue;
803-
else if (start == *uids - 1)
804+
else if (start == *uid - 1)
804805
snprintf(range, sizeof(range), "%u", start);
805806
else
806-
snprintf(range, sizeof(range), "%u-%u", start, *uids - 1);
807+
snprintf(range, sizeof(range), "%u-%u", start, *uid - 1);
807808
ranges = concat_and_free(ranges, " ", range);
808809
if (++args_per_command % 18 == 0) {
809810
cndc("network users add %u %s", netid, ranges);
@@ -816,8 +817,8 @@ static void set_users(unsigned int netid, const char *excluded_applications, con
816817
ranges = concat_and_free(ranges, " ", range);
817818
}
818819
} else {
819-
for (uids = get_uid_list(included_applications); *uids; ++uids) {
820-
snprintf(range, sizeof(range), "%u", *uids);
820+
for (uid = uids = get_uid_list(included_applications); *uid; ++uid) {
821+
snprintf(range, sizeof(range), "%u", *uid);
821822
ranges = concat_and_free(ranges, " ", range);
822823
if (++args_per_command % 18 == 0) {
823824
cndc("network users add %u %s", netid, ranges);

0 commit comments

Comments
 (0)