diff options
| author | Lars Ingebrigtsen | 2019-07-10 15:23:27 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-07-10 15:23:27 +0200 |
| commit | 09c805a40591a73591d6a609cf74ae7ce3ddd93a (patch) | |
| tree | c42cd790c02d5dd6f2a64e43288b48089f585948 | |
| parent | 08f0b0b98c53c4d5cf92b6dc57463e5b356043c4 (diff) | |
| download | emacs-09c805a40591a73591d6a609cf74ae7ce3ddd93a.tar.gz emacs-09c805a40591a73591d6a609cf74ae7ce3ddd93a.zip | |
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.
| -rw-r--r-- | lisp/comint.el | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index fbb67360df6..55e64865a27 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -2372,6 +2372,8 @@ Security bug: your string can still be temporarily recovered with | |||
| 2372 | 2372 | ||
| 2373 | (define-obsolete-function-alias 'send-invisible #'comint-send-invisible "27.1") | 2373 | (define-obsolete-function-alias 'send-invisible #'comint-send-invisible "27.1") |
| 2374 | 2374 | ||
| 2375 | (defvar comint--prompt-recursion-depth 0) | ||
| 2376 | |||
| 2375 | (defun comint-watch-for-password-prompt (string) | 2377 | (defun comint-watch-for-password-prompt (string) |
| 2376 | "Prompt in the minibuffer for password and send without echoing. | 2378 | "Prompt in the minibuffer for password and send without echoing. |
| 2377 | Looks for a match to `comint-password-prompt-regexp' in order | 2379 | 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'." | |||
| 2382 | (string-match comint-password-prompt-regexp string)) | 2384 | (string-match comint-password-prompt-regexp string)) |
| 2383 | (when (string-match "^[ \n\r\t\v\f\b\a]+" string) | 2385 | (when (string-match "^[ \n\r\t\v\f\b\a]+" string) |
| 2384 | (setq string (replace-match "" t t string))) | 2386 | (setq string (replace-match "" t t string))) |
| 2385 | (comint-send-invisible string))) | 2387 | (let ((comint--prompt-recursion-depth (1+ comint--prompt-recursion-depth))) |
| 2388 | (if (> comint--prompt-recursion-depth 10) | ||
| 2389 | (message "Password prompt recursion too deep") | ||
| 2390 | (comint-send-invisible string))))) | ||
| 2386 | 2391 | ||
| 2387 | ;; Low-level process communication | 2392 | ;; Low-level process communication |
| 2388 | 2393 | ||