|
| 1 | +From 820f0793f0b46448928905552726c1f1b999062f Mon Sep 17 00:00:00 2001 |
| 2 | +From: Xi Lu <lx@shellcodes.org> |
| 3 | +Date: Tue, 10 Oct 2023 22:20:05 +0800 |
| 4 | +Subject: [PATCH] Fix man.el shell injection vulnerability |
| 5 | + |
| 6 | +* lisp/man.el (Man-translate-references): Fix shell injection |
| 7 | +vulnerability. (Bug#66390) |
| 8 | +* test/lisp/man-tests.el (man-tests-Man-translate-references): New |
| 9 | +test. |
| 10 | +--- |
| 11 | + lisp/man.el | 6 +++++- |
| 12 | + test/lisp/man-tests.el | 12 ++++++++++++ |
| 13 | + 2 files changed, 17 insertions(+), 1 deletion(-) |
| 14 | + |
| 15 | +diff --git a/lisp/man.el b/lisp/man.el |
| 16 | +index 55cb9383bec1..d96396483d39 100644 |
| 17 | +--- a/lisp/man.el |
| 18 | ++++ b/lisp/man.el |
| 19 | +@@ -761,7 +761,11 @@ and the `Man-section-translations-alist' variables)." |
| 20 | + (setq name (match-string 2 ref) |
| 21 | + section (match-string 1 ref)))) |
| 22 | + (if (string= name "") |
| 23 | +- ref ; Return the reference as is |
| 24 | ++ ;; see Bug#66390 |
| 25 | ++ (mapconcat 'identity |
| 26 | ++ (mapcar #'shell-quote-argument |
| 27 | ++ (split-string ref "\\s-+")) |
| 28 | ++ " ") ; Return the reference as is |
| 29 | + (if Man-downcase-section-letters-flag |
| 30 | + (setq section (downcase section))) |
| 31 | + (while slist |
| 32 | +diff --git a/test/lisp/man-tests.el b/test/lisp/man-tests.el |
| 33 | +index 140482ee6222..11f5f805e43f 100644 |
| 34 | +--- a/test/lisp/man-tests.el |
| 35 | ++++ b/test/lisp/man-tests.el |
| 36 | +@@ -161,6 +161,18 @@ DESCRIPTION |
| 37 | + (let ((button (button-at (match-beginning 0)))) |
| 38 | + (should (and button (eq 'Man-xref-header-file (button-type button)))))))))) |
| 39 | + |
| 40 | ++(ert-deftest man-tests-Man-translate-references () |
| 41 | ++ (should (equal (Man-translate-references "basename") |
| 42 | ++ "basename")) |
| 43 | ++ (should (equal (Man-translate-references "basename(3)") |
| 44 | ++ "3 basename")) |
| 45 | ++ (should (equal (Man-translate-references "basename(3v)") |
| 46 | ++ "3v basename")) |
| 47 | ++ (should (equal (Man-translate-references ";id") |
| 48 | ++ "\\;id")) |
| 49 | ++ (should (equal (Man-translate-references "-k basename") |
| 50 | ++ "-k basename"))) |
| 51 | ++ |
| 52 | + (provide 'man-tests) |
| 53 | + |
| 54 | + ;;; man-tests.el ends here |
0 commit comments