84b277
From e02c7fe6cff60803c19dcfe3c21c69bc9c8bdef8 Mon Sep 17 00:00:00 2001
84b277
From: Lennart Poettering <lennart@poettering.net>
84b277
Date: Tue, 25 Mar 2014 01:27:05 +0100
84b277
Subject: [PATCH] ask-password: when the user types a overly long password,
84b277
 beep and refuse
84b277
MIME-Version: 1.0
84b277
Content-Type: text/plain; charset=UTF-8
84b277
Content-Transfer-Encoding: 8bit
84b277
84b277
Based on a similar patch from David Härdeman.
84b277
84b277
(cherry-picked from 036eeac5a1799fa2c0ae11a14d8c667b5d303189)
84b277
84b277
Resolves: #1147524
84b277
---
84b277
 src/shared/ask-password-api.c | 5 +++++
84b277
 1 file changed, 5 insertions(+)
84b277
84b277
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
84b277
index 4557155..25367d0 100644
84b277
--- a/src/shared/ask-password-api.c
84b277
+++ b/src/shared/ask-password-api.c
84b277
@@ -207,6 +207,11 @@ int ask_password_tty(
84b277
                         if (ttyfd >= 0)
84b277
                                 loop_write(ttyfd, "(no echo) ", 10, false);
84b277
                 } else {
84b277
+                        if (p >= sizeof(passphrase)-1) {
84b277
+                                loop_write(ttyfd, "\a", 1, false);
84b277
+                                continue;
84b277
+                        }
84b277
+
84b277
                         passphrase[p++] = c;
84b277
 
84b277
                         if (!silent_mode && ttyfd >= 0)