network: Be extra pedantic in network_get_psk

Check that the passphrase to PSK conversion actually succeeds.
This commit is contained in:
Denis Kenzior 2019-10-17 17:33:56 -05:00
parent a043f26134
commit 5dbccee798
1 changed files with 6 additions and 5 deletions

View File

@ -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;
}