Blob Blame History Raw
From e02c7fe6cff60803c19dcfe3c21c69bc9c8bdef8 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 25 Mar 2014 01:27:05 +0100
Subject: [PATCH] ask-password: when the user types a overly long password,
 beep and refuse
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Based on a similar patch from David Härdeman.

(cherry-picked from 036eeac5a1799fa2c0ae11a14d8c667b5d303189)

Resolves: #1147524
---
 src/shared/ask-password-api.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index 4557155..25367d0 100644
--- a/src/shared/ask-password-api.c
+++ b/src/shared/ask-password-api.c
@@ -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)