readline: backport a patch to fix for caller setting rl_prompt to NULL

I've observed this issue affecting iwctl and connmanctl.

Patching readline solves the issue.

The original patch from [5] mixes many fixes in one commit. I've extract
only what matters to solve the issues observed with connman and iwd. The
final patch is the same patch sent by readline author to readline's mail list [6].

References:

1: https://gitlab.archlinux.org/archlinux/packaging/packages/readline/-/issues/1
2: b30636dc66
3: https://lists.gnu.org/archive/html/bug-readline/2025-07/msg00007.html
4: https://lore.kernel.org/connman/20251018212411.181909-1-jsbronder@cold-front.org/
5: https://cgit.git.savannah.gnu.org/cgit/readline.git/commit/display.c?h=devel&id=488d7edc22894d30b6de7f2d4190bf7403f63ffd
6: https://lists.gnu.org/archive/html/bug-readline/2025-07/txtmA7rksnmmi.txt

Fixes [YOCTO #16047]

CC  Paul Barker <paul@pbarker.dev>

CC: Jose Quaresma <quaresma.jose@gmail.com>
CC: Khem Raj <raj.khem@gmail.com>
(From OE-Core rev: 8ce0359c4eade11b445bc227c42f7f1212a2d9c3)

Signed-off-by: João Henrique Ferreira de Freitas <joaohf@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
João Henrique Ferreira de Freitas 2025-11-03 15:14:09 -03:00 committed by Richard Purdie
parent ec569c235d
commit 4c92caf622
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,40 @@
From a0a4c011c0c5e598c5b51cbf81d3b4501fa72e0c Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Thu, 30 Oct 2025 14:19:41 -0300
Subject: [PATCH] fix for caller setting rl_prompt to NULL
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The original patch came from [1, 2] and it has been integrated into
readline git repository, commit (488d7edc22894d30b6de7f2d4190bf7403f63ffd)
This patch has only the fix needed to solve the follow issues [3,4].
I added the original author as this patch has been sent through readline mail
list.
1: https://lists.gnu.org/archive/html/bug-readline/2025-07/msg00007.html
2: https://lists.gnu.org/archive/html/bug-readline/2025-07/txtmA7rksnmmi.txt
3: https://lore.kernel.org/connman/20251018212411.181909-1-jsbronder@cold-front.org/
4: https://gitlab.archlinux.org/archlinux/packaging/packages/readline/-/issues/1
Upstream-Status: Backport [https://cgit.git.savannah.gnu.org/cgit/readline.git/commit/display.c?h=devel&id=488d7edc22894d30b6de7f2d4190bf7403f63ffd]
Signed-off-by: João Henrique Ferreira de Freitas <joaohf@gmail.com>
---
display.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/display.c b/display.c
index 9aa8c7b..edb525d 100644
--- a/display.c
+++ b/display.c
@@ -783,7 +783,7 @@ _rl_optimize_redisplay (void)
/* Useful shorthand used by rl_redisplay, update_line, rl_move_cursor_relative */
#define INVIS_FIRST() (local_prompt_invis_chars[0])
-#define WRAP_OFFSET(line, offset) ((line <= prompt_last_screen_line) ? local_prompt_invis_chars[line] : 0)
+#define WRAP_OFFSET(line, offset) ((line <= prompt_last_screen_line && local_prompt_invis_chars) ? local_prompt_invis_chars[line] : 0)
#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))

View File

@ -2,6 +2,7 @@ require readline.inc
SRC_URI += "file://norpath.patch \
file://fix-for-readline-event-hook.patch \
file://fix-for-caller-setting-rl_prompt-to-NULL.patch \
"
SRC_URI[archive.sha256sum] = "fe5383204467828cd495ee8d1d3c037a7eba1389c22bc6a041f627976f9061cc"