File: readline82-012.diff

package info (click to toggle)
readline 8.3-3
  • links: PTS
  • area: main
  • in suites: forky
  • size: 9,764 kB
  • sloc: ansic: 30,409; sh: 6,600; perl: 4,105; makefile: 1,856
file content (73 lines) | stat: -rw-r--r-- 2,286 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
			   READLINE PATCH REPORT
			   =====================

Readline-Release: 8.2
Patch-ID: readline82-012

Bug-Reported-by:	Grisha Levit <grishalevit@gmail.com>
Bug-Reference-ID:	<CAMu=BroaH+41uumYt89FPqt8Fsatj-d6mZzmPV2HZYjtcbvbvw@mail.gmail.com>
Bug-Reference-URL:	https://lists.gnu.org/archive/html/bug-readline/2023-11/msg00019.html

Bug-Description:

If a user happens to bind do-lowercase-version to something that isn't a
capital letter, so _rl_to_lower doesn't change anything and the result is
still bound to do-lowercase-version, readline can recurse infinitely.

--- a/isearch.c
+++ b/isearch.c
@@ -428,7 +428,11 @@ add_character:
 	{
 	  f = cxt->keymap[c].function;
 	  if (f == rl_do_lowercase_version)
-	    f = cxt->keymap[_rl_to_lower (c)].function;
+	    {
+	      f = cxt->keymap[_rl_to_lower (c)].function;
+	      if (f == rl_do_lowercase_version)
+		f = rl_insert;
+	    }
 	}
 
       if (f == rl_reverse_search_history)
--- a/patchlevel
+++ b/patchlevel
@@ -1,3 +1,3 @@
 # Do not edit -- exists only for use by patch
 
-11
+12
--- a/readline.c
+++ b/readline.c
@@ -899,8 +899,17 @@ _rl_dispatch_subseq (register int key, K
 	{
 	  /* Special case rl_do_lowercase_version (). */
 	  if (func == rl_do_lowercase_version)
-	    /* Should we do anything special if key == ANYOTHERKEY? */
-	    return (_rl_dispatch (_rl_to_lower ((unsigned char)key), map));
+	    {
+	      /* Should we do anything special if key == ANYOTHERKEY? */
+	      newkey = _rl_to_lower ((unsigned char)key);
+	      if (newkey != key)
+		return (_rl_dispatch (newkey, map));
+	      else
+		{
+		  rl_ding ();		/* gentle failure */
+		  return 0;
+		}
+	    }
 
 	  rl_executing_keymap = map;
 	  rl_executing_key = key;
@@ -1109,7 +1118,11 @@ _rl_subseq_result (int r, Keymap map, in
       type = m[ANYOTHERKEY].type;
       func = m[ANYOTHERKEY].function;
       if (type == ISFUNC && func == rl_do_lowercase_version)
-	r = _rl_dispatch (_rl_to_lower ((unsigned char)key), map);
+	{
+	  int newkey = _rl_to_lower ((unsigned char)key);
+	  /* check that there is actually a lowercase version to avoid infinite recursion */
+	  r = (newkey != key) ? _rl_dispatch (newkey, map) : 1;
+	}
       else if (type == ISFUNC)
 	{
 	  /* If we shadowed a function, whatever it is, we somehow need a