wg-quick: android: do not free iterated pointer
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
		
							parent
							
								
									7a321ce808
								
							
						
					
					
						commit
						265e81a344
					
				@ -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)
 | 
					static void set_users(unsigned int netid, const char *excluded_applications, const char *included_applications)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	_cleanup_free_ uid_t *uids = NULL;
 | 
						_cleanup_free_ uid_t *uids = NULL;
 | 
				
			||||||
 | 
						uid_t *uid;
 | 
				
			||||||
	unsigned int args_per_command = 0;
 | 
						unsigned int args_per_command = 0;
 | 
				
			||||||
	_cleanup_free_ char *ranges = NULL;
 | 
						_cleanup_free_ char *ranges = NULL;
 | 
				
			||||||
	char range[22];
 | 
						char range[22];
 | 
				
			||||||
@ -796,14 +797,14 @@ static void set_users(unsigned int netid, const char *excluded_applications, con
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (excluded_applications || !included_applications) {
 | 
						if (excluded_applications || !included_applications) {
 | 
				
			||||||
		uids = get_uid_list(excluded_applications);
 | 
							uid = uids = get_uid_list(excluded_applications);
 | 
				
			||||||
		for (start = 0; *uids; start = *uids + 1, ++uids) {
 | 
							for (start = 0; *uid; start = *uid + 1, ++uid) {
 | 
				
			||||||
			if (start > *uids - 1)
 | 
								if (start > *uid - 1)
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
			else if (start == *uids - 1)
 | 
								else if (start == *uid - 1)
 | 
				
			||||||
				snprintf(range, sizeof(range), "%u", start);
 | 
									snprintf(range, sizeof(range), "%u", start);
 | 
				
			||||||
			else
 | 
								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);
 | 
								ranges = concat_and_free(ranges, " ", range);
 | 
				
			||||||
			if (++args_per_command % 18 == 0) {
 | 
								if (++args_per_command % 18 == 0) {
 | 
				
			||||||
				cndc("network users add %u %s", netid, ranges);
 | 
									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);
 | 
								ranges = concat_and_free(ranges, " ", range);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		for (uids = get_uid_list(included_applications); *uids; ++uids) {
 | 
							for (uid = uids = get_uid_list(included_applications); *uid; ++uid) {
 | 
				
			||||||
			snprintf(range, sizeof(range), "%u", *uids);
 | 
								snprintf(range, sizeof(range), "%u", *uid);
 | 
				
			||||||
			ranges = concat_and_free(ranges, " ", range);
 | 
								ranges = concat_and_free(ranges, " ", range);
 | 
				
			||||||
			if (++args_per_command % 18 == 0) {
 | 
								if (++args_per_command % 18 == 0) {
 | 
				
			||||||
				cndc("network users add %u %s", netid, ranges);
 | 
									cndc("network users add %u %s", netid, ranges);
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user