From: Adolf Belka <adolf.belka@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH] readline: Update patches to include 11 - 13
Date: Tue, 13 Aug 2024 18:19:46 +0200 [thread overview]
Message-ID: <20240813162000.1113995-11-adolf.belka@ipfire.org> (raw)
In-Reply-To: <20240813162000.1113995-1-adolf.belka@ipfire.org>
[-- Attachment #1: Type: text/plain, Size: 13590 bytes --]
- Update patches from 1 - 10 to 1 - 13
- Update of rootfile not required
- Changelog of patches
11 Some systems (e.g., macOS) send signals early on in interactive initialization,
so readline should retry a failed open of the init file.
12 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.
13 When readline is accumulating bytes until it reads a complete multibyte
character, reading a byte that makes the multibyte character invalid can
result in discarding the bytes in the partial character.
Signed-off-by: Adolf Belka <adolf.belka(a)ipfire.org>
---
lfs/readline | 2 +-
src/patches/readline/readline82-011 | 75 +++++++++
src/patches/readline/readline82-012 | 93 +++++++++++
src/patches/readline/readline82-013 | 234 ++++++++++++++++++++++++++++
4 files changed, 403 insertions(+), 1 deletion(-)
create mode 100644 src/patches/readline/readline82-011
create mode 100644 src/patches/readline/readline82-012
create mode 100644 src/patches/readline/readline82-013
diff --git a/lfs/readline b/lfs/readline
index 05d140de1..cfe4cbf18 100644
--- a/lfs/readline
+++ b/lfs/readline
@@ -72,7 +72,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
@$(PREBUILD)
@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
- for i in $$(seq 1 10); do \
+ for i in $$(seq 1 13); do \
cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/readline/readline82-$$(printf "%03d" "$${i}") || exit 1; \
done
diff --git a/src/patches/readline/readline82-011 b/src/patches/readline/readline82-011
new file mode 100644
index 000000000..3ad7a8ffd
--- /dev/null
+++ b/src/patches/readline/readline82-011
@@ -0,0 +1,75 @@
+ READLINE PATCH REPORT
+ =====================
+
+Readline-Release: 8.2
+Patch-ID: readline82-011
+
+Bug-Reported-by: Grisha Levit <grishalevit(a)gmail.com>
+Bug-Reference-ID: <CAMu=BrqWa_iNkiEwchpFmtrUhFrAanOO8pjy7VCKqRKUvqdsbw(a)mail.gmail.com>
+Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2024-02/msg00075.html
+
+Bug-Description:
+
+Patch (apply with `patch -p0'):
+
+Some systems (e.g., macOS) send signals early on in interactive initialization,
+so readline should retry a failed open of the init file.
+
+*** ../readline-8.2-patched/bind.c Wed Feb 9 11:02:22 2022
+--- bind.c Tue Apr 23 15:07:13 2024
+***************
+*** 979,987 ****
+ int i, file;
+
+! file = -1;
+! if (((file = open (filename, O_RDONLY, 0666)) < 0) || (fstat (file, &finfo) < 0))
+ {
+ if (file >= 0)
+ close (file);
+ return ((char *)NULL);
+ }
+--- 969,986 ----
+ int i, file;
+
+! file = open (filename, O_RDONLY, 0666);
+! /* If the open is interrupted, retry once */
+! if (file < 0 && errno == EINTR)
+ {
++ RL_CHECK_SIGNALS ();
++ file = open (filename, O_RDONLY, 0666);
++ }
++
++ if ((file < 0) || (fstat (file, &finfo) < 0))
++ {
++ i = errno;
+ if (file >= 0)
+ close (file);
++ errno = i;
+ return ((char *)NULL);
+ }
+***************
+*** 992,999 ****
+--- 991,1001 ----
+ if (file_size != finfo.st_size || file_size + 1 < file_size)
+ {
++ i = errno;
+ if (file >= 0)
+ close (file);
+ #if defined (EFBIG)
+ errno = EFBIG;
++ #else
++ errno = i;
+ #endif
+ return ((char *)NULL);
+
+*** ../readline-8.2/patchlevel 2013-11-15 08:11:11.000000000 -0500
+--- patchlevel 2014-03-21 08:28:40.000000000 -0400
+***************
+*** 1,3 ****
+ # Do not edit -- exists only for use by patch
+
+! 10
+--- 1,3 ----
+ # Do not edit -- exists only for use by patch
+
+! 11
diff --git a/src/patches/readline/readline82-012 b/src/patches/readline/readline82-012
new file mode 100644
index 000000000..cbcb4cdaf
--- /dev/null
+++ b/src/patches/readline/readline82-012
@@ -0,0 +1,93 @@
+ READLINE PATCH REPORT
+ =====================
+
+Readline-Release: 8.2
+Patch-ID: readline82-012
+
+Bug-Reported-by: Grisha Levit <grishalevit(a)gmail.com>
+Bug-Reference-ID: <CAMu=BroaH+41uumYt89FPqt8Fsatj-d6mZzmPV2HZYjtcbvbvw(a)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.
+
+Patch (apply with `patch -p0'):
+
+*** ../readline-8.2-patched/readline.c Thu Aug 11 18:35:37 2022
+--- readline.c Fri Feb 2 12:05:36 2024
+***************
+*** 900,905 ****
+ /* 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));
+
+ rl_executing_keymap = map;
+--- 912,926 ----
+ /* Special case rl_do_lowercase_version (). */
+ if (func == rl_do_lowercase_version)
+! {
+! /* 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;
+***************
+*** 1110,1114 ****
+ func = m[ANYOTHERKEY].function;
+ if (type == ISFUNC && func == rl_do_lowercase_version)
+! r = _rl_dispatch (_rl_to_lower ((unsigned char)key), map);
+ else if (type == ISFUNC)
+ {
+--- 1131,1139 ----
+ func = m[ANYOTHERKEY].function;
+ if (type == ISFUNC && func == rl_do_lowercase_version)
+! {
+! 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)
+ {
+
+*** ../readline-8.2-patched/isearch.c Thu Aug 11 18:35:37 2022
+--- isearch.c Fri Feb 2 12:05:36 2024
+***************
+*** 429,433 ****
+ f = cxt->keymap[c].function;
+ if (f == rl_do_lowercase_version)
+! f = cxt->keymap[_rl_to_lower (c)].function;
+ }
+
+--- 431,439 ----
+ f = cxt->keymap[c].function;
+ if (f == rl_do_lowercase_version)
+! {
+! f = cxt->keymap[_rl_to_lower (c)].function;
+! if (f == rl_do_lowercase_version)
+! f = rl_insert;
+! }
+ }
+
+
+*** ../readline-8.2/patchlevel 2013-11-15 08:11:11.000000000 -0500
+--- patchlevel 2014-03-21 08:28:40.000000000 -0400
+***************
+*** 1,3 ****
+ # Do not edit -- exists only for use by patch
+
+! 11
+--- 1,3 ----
+ # Do not edit -- exists only for use by patch
+
+! 12
diff --git a/src/patches/readline/readline82-013 b/src/patches/readline/readline82-013
new file mode 100644
index 000000000..cb4164fbe
--- /dev/null
+++ b/src/patches/readline/readline82-013
@@ -0,0 +1,234 @@
+ READLINE PATCH REPORT
+ =====================
+
+Readline-Release: 8.2
+Patch-ID: readline82-013
+
+Bug-Reported-by: Grisha Levit <grishalevit(a)gmail.com>
+Bug-Reference-ID: <CAMu=Brrv5qKY6LPfw8PxqNXNO8rNsZo0Fb=BcFb-uHObWPqnrw(a)mail.gmail.
+Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2023-04/msg00082.html
+
+Bug-Description:
+
+When readline is accumulating bytes until it reads a complete multibyte
+character, reading a byte that makes the multibyte character invalid can
+result in discarding the bytes in the partial character.
+
+Patch (apply with `patch -p0'):
+
+*** ../readline-8.2-patched/text.c Mon May 1 09:37:52 2023
+--- text.c Mon May 29 12:22:29 2023
+***************
+*** 86,90 ****
+ rl_insert_text (const char *string)
+ {
+! register int i, l;
+
+ l = (string && *string) ? strlen (string) : 0;
+--- 86,91 ----
+ rl_insert_text (const char *string)
+ {
+! register int i;
+! size_t l;
+
+ l = (string && *string) ? strlen (string) : 0;
+***************
+*** 705,709 ****
+ /* Insert the character C at the current location, moving point forward.
+ If C introduces a multibyte sequence, we read the whole sequence and
+! then insert the multibyte char into the line buffer. */
+ int
+ _rl_insert_char (int count, int c)
+--- 706,714 ----
+ /* Insert the character C at the current location, moving point forward.
+ If C introduces a multibyte sequence, we read the whole sequence and
+! then insert the multibyte char into the line buffer.
+! If C == 0, we immediately insert any pending partial multibyte character,
+! assuming that we have read a character that doesn't map to self-insert.
+! This doesn't completely handle characters that are part of a multibyte
+! character but map to editing functions. */
+ int
+ _rl_insert_char (int count, int c)
+***************
+*** 719,727 ****
+ #endif
+
+ if (count <= 0)
+ return 0;
+
+! #if defined (HANDLE_MULTIBYTE)
+! if (MB_CUR_MAX == 1 || rl_byte_oriented)
+ {
+ incoming[0] = c;
+--- 724,749 ----
+ #endif
+
++ #if !defined (HANDLE_MULTIBYTE)
+ if (count <= 0)
+ return 0;
++ #else
++ if (count < 0)
++ return 0;
++ if (count == 0)
++ {
++ if (pending_bytes_length == 0)
++ return 0;
++ if (stored_count <= 0)
++ stored_count = count;
++ else
++ count = stored_count;
+
+! memcpy (incoming, pending_bytes, pending_bytes_length);
+! incoming[pending_bytes_length] = '\0';
+! incoming_length = pending_bytes_length;
+! pending_bytes_length = 0;
+! memset (&ps, 0, sizeof (mbstate_t));
+! }
+! else if (MB_CUR_MAX == 1 || rl_byte_oriented)
+ {
+ incoming[0] = c;
+***************
+*** 731,734 ****
+--- 753,759 ----
+ else if (_rl_utf8locale && (c & 0x80) == 0)
+ {
++ if (pending_bytes_length)
++ _rl_insert_char (0, 0);
++
+ incoming[0] = c;
+ incoming[1] = '\0';
+***************
+*** 765,769 ****
+ incoming_length = 1;
+ pending_bytes_length--;
+! memmove (pending_bytes, pending_bytes + 1, pending_bytes_length);
+ /* Clear the state of the byte sequence, because in this case the
+ effect of mbstate is undefined. */
+--- 790,795 ----
+ incoming_length = 1;
+ pending_bytes_length--;
+! if (pending_bytes_length)
+! memmove (pending_bytes, pending_bytes + 1, pending_bytes_length);
+ /* Clear the state of the byte sequence, because in this case the
+ effect of mbstate is undefined. */
+***************
+*** 828,832 ****
+--- 854,862 ----
+ xfree (string);
+
++ #if defined (HANDLE_MULTIBYTE)
++ return (pending_bytes_length != 0);
++ #else
+ return 0;
++ #endif
+ }
+
+***************
+*** 861,864 ****
+--- 891,896 ----
+ incoming_length = 0;
+ stored_count = 0;
++
++ return (pending_bytes_length != 0);
+ #else /* !HANDLE_MULTIBYTE */
+ char str[TEXT_COUNT_MAX+1];
+***************
+*** 874,880 ****
+ count -= decreaser;
+ }
+- #endif /* !HANDLE_MULTIBYTE */
+
+ return 0;
+ }
+
+--- 906,912 ----
+ count -= decreaser;
+ }
+
+ return 0;
++ #endif /* !HANDLE_MULTIBYTE */
+ }
+
+***************
+*** 904,910 ****
+ stored_count = 0;
+ }
+! #endif
+!
+ return 0;
+ }
+
+--- 936,944 ----
+ stored_count = 0;
+ }
+!
+! return (pending_bytes_length != 0);
+! #else
+ return 0;
++ #endif
+ }
+
+***************
+*** 984,987 ****
+--- 1018,1026 ----
+ }
+
++ /* If we didn't insert n and there are pending bytes, we need to insert
++ them if _rl_insert_char didn't do that on its own. */
++ if (r == 1 && rl_insert_mode == RL_IM_INSERT)
++ r = _rl_insert_char (0, 0); /* flush partial multibyte char */
++
+ if (n != (unsigned short)-2) /* -2 = sentinel value for having inserted N */
+ {
+***************
+*** 1055,1058 ****
+--- 1094,1099 ----
+ rl_quoted_insert (int count, int key)
+ {
++ int r;
++
+ /* Let's see...should the callback interface futz with signal handling? */
+ #if defined (HANDLE_SIGNALS)
+***************
+*** 1073,1085 ****
+ if (count < 0)
+ {
+- int r;
+-
+ do
+ r = _rl_insert_next (1);
+ while (r == 0 && ++count < 0);
+- return r;
+ }
+
+! return _rl_insert_next (count);
+ }
+
+--- 1114,1128 ----
+ if (count < 0)
+ {
+ do
+ r = _rl_insert_next (1);
+ while (r == 0 && ++count < 0);
+ }
++ else
++ r = _rl_insert_next (count);
+
+! if (r == 1)
+! _rl_insert_char (0, 0); /* insert partial multibyte character */
+!
+! return r;
+ }
+
+
+*** ../readline-8.2/patchlevel 2013-11-15 08:11:11.000000000 -0500
+--- patchlevel 2014-03-21 08:28:40.000000000 -0400
+***************
+*** 1,3 ****
+ # Do not edit -- exists only for use by patch
+
+! 12
+--- 1,3 ----
+ # Do not edit -- exists only for use by patch
+
+! 13
--
2.46.0
next prev parent reply other threads:[~2024-08-13 16:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 16:19 [PATCH] bash: Update to include patches 27 to 32 Adolf Belka
2024-08-13 16:19 ` [PATCH 1/2] cups-filters: Ship due to sobump in poppler-24.08.0 Adolf Belka
2024-08-13 16:25 ` Adolf Belka
2024-08-13 16:19 ` [PATCH] curl: Update to version 8.9.1 Adolf Belka
2024-08-13 16:19 ` [PATCH] exfatprogs: Update to version 1.2.5 Adolf Belka
2024-08-13 16:19 ` [PATCH] git: Update to version 2.46.0 Adolf Belka
2024-08-13 16:19 ` [PATCH] hwdata: Update to the latest versions of pci.ids & usb.ids Adolf Belka
2024-08-13 16:19 ` [PATCH] iproute2: Update to version 6.10.0 Adolf Belka
2024-08-13 16:19 ` [PATCH] knot: Update to version 3.3.8 Adolf Belka
2024-08-13 16:19 ` [PATCH] lz4: Update to version 1.10.0 Adolf Belka
2024-08-13 16:19 ` [PATCH 1/2] ncdu: Update to version 1.20 Adolf Belka
2024-08-13 16:24 ` Adolf Belka
2024-08-13 16:19 ` Adolf Belka [this message]
2024-08-13 16:19 ` [PATCH] sdl2: Update to version 2.30.6 Adolf Belka
2024-08-13 16:19 ` [PATCH] strace: Update to version 6.10 Adolf Belka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240813162000.1113995-11-adolf.belka@ipfire.org \
--to=adolf.belka@ipfire.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox