]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_passphrase: Output errors to stderr
authorSam Tygier <samtygier@yahoo.co.uk>
Mon, 23 Dec 2019 15:20:20 +0000 (15:20 +0000)
committerJouni Malinen <j@w1.fi>
Tue, 24 Dec 2019 09:14:27 +0000 (11:14 +0200)
The stdout of wpa_passphrase is often piped directly into the
wpa_supplicant config file. In case of errors these will be written to
the file and possibly not noticed by the user.

Use fprintf to print errors to stderr.

Signed-off-by: Sam Tygier <samtygier@yahoo.co.uk>
wpa_supplicant/wpa_passphrase.c

index adca1cce13ee07bee83711f3cd7d8f8205e39fbd..538997e62580a33c539dc3f584288a07ff694d26 100644 (file)
@@ -31,9 +31,9 @@ int main(int argc, char *argv[])
        if (argc > 2) {
                passphrase = argv[2];
        } else {
-               printf("# reading passphrase from stdin\n");
+               fprintf(stderr, "# reading passphrase from stdin\n");
                if (fgets(buf, sizeof(buf), stdin) == NULL) {
-                       printf("Failed to read passphrase\n");
+                       fprintf(stderr, "Failed to read passphrase\n");
                        return 1;
                }
                buf[sizeof(buf) - 1] = '\0';
@@ -50,11 +50,11 @@ int main(int argc, char *argv[])
 
        len = os_strlen(passphrase);
        if (len < 8 || len > 63) {
-               printf("Passphrase must be 8..63 characters\n");
+               fprintf(stderr, "Passphrase must be 8..63 characters\n");
                return 1;
        }
        if (has_ctrl_char((u8 *) passphrase, len)) {
-               printf("Invalid passphrase character\n");
+               fprintf(stderr, "Invalid passphrase character\n");
                return 1;
        }