~linuxhackerman/iwd

1f3c8b0139e8b8dc8221ad7a72a52812f40f50b7 — Linus Heckemann 1 year, 2 months ago 2e475b7
Allocate strings on stack
1 files changed, 2 insertions(+), 7 deletions(-)

M src/network.c
M src/network.c => src/network.c +2 -7
@@ 859,24 859,19 @@ static struct l_dbus_message *network_connect_psk(struct network *network,
		size_t at = 0;
		if (handle != NULL && network->info != NULL) {
			char *cfgpath_ = network->info->ops->get_file_path(network->info);
			char *cfgpath = calloc(1, PATH_MAX);
			char cfgpath[PATH_MAX];
			if (realpath(cfgpath_, cfgpath) != NULL) {
				char *tocheck = calloc(1, PATH_MAX);
				char tocheck[PATH_MAX];
				while (getline(&line, &at, handle) != -1) {
					*index(line, '\n') = '\0';
					snprintf(tocheck, PATH_MAX - 1, "/var/lib/iwd/%s", line);
					if (strcmp(tocheck, cfgpath) == 0) {
						free(tocheck);
						free(line);
						free(cfgpath);
						fclose(handle);

						return dbus_error_file_is_a_nix_store_path(message, network->ssid);
					}
				}
				free(tocheck);
			}
			free(cfgpath);
			free(line);
			fclose(handle);
		}