]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Check pbkdf2_sha1() result when generating PSK from PSK file
authorJouni Malinen <j@w1.fi>
Sat, 15 Feb 2020 15:10:08 +0000 (17:10 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 15 Feb 2020 15:10:08 +0000 (17:10 +0200)
This function can fail in theory, so check the return value.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/ap/ap_config.c

index 27c4b48e4c56edd03fd39380531131fb3bcd5b43..d35423ecafd7162cdbdce5e71575e41dc530dcc5 100644 (file)
@@ -379,11 +379,10 @@ static int hostapd_config_read_wpa_psk(const char *fname,
                len = os_strlen(pos);
                if (len == 64 && hexstr2bin(pos, psk->psk, PMK_LEN) == 0)
                        ok = 1;
-               else if (len >= 8 && len < 64) {
-                       pbkdf2_sha1(pos, ssid->ssid, ssid->ssid_len,
-                                   4096, psk->psk, PMK_LEN);
+               else if (len >= 8 && len < 64 &&
+                        pbkdf2_sha1(pos, ssid->ssid, ssid->ssid_len,
+                                    4096, psk->psk, PMK_LEN) == 0)
                        ok = 1;
-               }
                if (!ok) {
                        wpa_printf(MSG_ERROR, "Invalid PSK '%s' on line %d in "
                                   "'%s'", pos, line, fname);