commit 5dbccee798861b10fcca04ec311296c47cab0f7b
parent a043f261347c14722f816d453920a5c407589e9b
Author: Denis Kenzior <denkenz@gmail.com>
Date: Thu, 17 Oct 2019 17:33:56 -0500
network: Be extra pedantic in network_get_psk
Check that the passphrase to PSK conversion actually succeeds.
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/network.c b/src/network.c
@@ -253,14 +253,15 @@ const uint8_t *network_get_psk(struct network *network)
if (network->psk)
return network->psk;
- if (!network->passphrase)
- return NULL;
-
network->psk = l_malloc(32);
- crypto_psk_from_passphrase(network->passphrase,
+ if (crypto_psk_from_passphrase(network->passphrase,
(unsigned char *)network->ssid,
- strlen(network->ssid), network->psk);
+ strlen(network->ssid),
+ network->psk) < 0) {
+ l_free(network->psk);
+ network->psk = NULL;
+ }
return network->psk;
}