ask-password: when the user types a overly long password, beep and refuse
authorLennart Poettering <lennart@poettering.net>
Tue, 25 Mar 2014 00:27:05 +0000 (01:27 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 25 Mar 2014 00:27:45 +0000 (01:27 +0100)
Based on a similar patch from David Härdeman.

src/shared/ask-password-api.c

index 117f0c6..96f16cc 100644 (file)
@@ -207,6 +207,11 @@ int ask_password_tty(
                         if (ttyfd >= 0)
                                 loop_write(ttyfd, "(no echo) ", 10, false);
                 } else {
+                        if (p >= sizeof(passphrase)-1) {
+                                loop_write(ttyfd, "\a", 1, false);
+                                continue;
+                        }
+
                         passphrase[p++] = c;
 
                         if (!silent_mode && ttyfd >= 0)