]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_passphrase: Reject invalid passphrase
authorJouni Malinen <jouni@qca.qualcomm.com>
Mon, 5 Dec 2016 13:36:56 +0000 (15:36 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 5 Dec 2016 13:36:56 +0000 (15:36 +0200)
Reject a passphrase with control characters instead of trying to write
out an example network configuration block with such control characters
included.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
wpa_supplicant/wpa_passphrase.c

index 9b568f0f7c672c84506b63ff0ad95af8adc15c21..adca1cce13ee07bee83711f3cd7d8f8205e39fbd 100644 (file)
@@ -17,6 +17,7 @@ int main(int argc, char *argv[])
        unsigned char psk[32];
        int i;
        char *ssid, *passphrase, buf[64], *pos;
+       size_t len;
 
        if (argc < 2) {
                printf("usage: wpa_passphrase <ssid> [passphrase]\n"
@@ -47,10 +48,15 @@ int main(int argc, char *argv[])
                passphrase = buf;
        }
 
-       if (os_strlen(passphrase) < 8 || os_strlen(passphrase) > 63) {
+       len = os_strlen(passphrase);
+       if (len < 8 || len > 63) {
                printf("Passphrase must be 8..63 characters\n");
                return 1;
        }
+       if (has_ctrl_char((u8 *) passphrase, len)) {
+               printf("Invalid passphrase character\n");
+               return 1;
+       }
 
        pbkdf2_sha1(passphrase, (u8 *) ssid, os_strlen(ssid), 4096, psk, 32);