emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 09c805a 2/2: Add recursion check for comint passwor


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 09c805a 2/2: Add recursion check for comint password prompting
Date: Wed, 10 Jul 2019 09:24:49 -0400 (EDT)

branch: master
commit 09c805a40591a73591d6a609cf74ae7ce3ddd93a
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Add recursion check for comint password prompting
    
    * lisp/comint.el (comint--prompt-recursion-depth): New variable
    (bug#33252).
    (comint-watch-for-password-prompt): Use it to avoid bugging out
    and making Emacs unusable when a shell script is prompting for
    passwords in an infloop.
---
 lisp/comint.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index fbb6736..55e6486 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2372,6 +2372,8 @@ Security bug: your string can still be temporarily 
recovered with
 
 (define-obsolete-function-alias 'send-invisible #'comint-send-invisible "27.1")
 
+(defvar comint--prompt-recursion-depth 0)
+
 (defun comint-watch-for-password-prompt (string)
   "Prompt in the minibuffer for password and send without echoing.
 Looks for a match to `comint-password-prompt-regexp' in order
@@ -2382,7 +2384,10 @@ This function could be in the list 
`comint-output-filter-functions'."
          (string-match comint-password-prompt-regexp string))
     (when (string-match "^[ \n\r\t\v\f\b\a]+" string)
       (setq string (replace-match "" t t string)))
-    (comint-send-invisible string)))
+    (let ((comint--prompt-recursion-depth (1+ comint--prompt-recursion-depth)))
+      (if (> comint--prompt-recursion-depth 10)
+          (message "Password prompt recursion too deep")
+        (comint-send-invisible string)))))
 
 ;; Low-level process communication
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]