Version 8.0 Ubuntu 20.04 Focal Fossa If rl_display is overridden as is done in libterm-readline-gnu-perl, i.e. for password entry, a segfault occurs _rl_update_final () at ./display.c:2972
See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=941326 The attached program rl-display.c reproduces the issue. I've attached a patch that fixes the problem. Ngā Mihi Gary -- Catalyst IT - Open Source Technologists DDI: +64 4 123 4567 | Mob: +64 21 123 4567 | Tel: +64 4 123 4567 | www.catalyst.net.nz CONFIDENTIALITY NOTICE: This email is intended for the named recipients only. It may contain privileged, confidential or copyright information. If you are not the named recipient, any use, reliance upon, disclosure or copying of this email or its attachments is unauthorised. If you have received this email in error, please reply via email or call +64 4 499 2267.
#include <config.h> #include <stdio.h> #include <stdlib.h> #include <readline/readline.h> void display(void) { } int main () { char *temp, *prompt; rl_redisplay_function = display; prompt = "readline$ "; temp = readline (prompt); /* Test for EOF. */ if (temp == 0) exit (1); printf ("%s\n", temp); free(temp); exit (0); }
From a93b5b31968bd07385a6cf2a8a1d0bdf1df9720e Mon Sep 17 00:00:00 2001 From: Chet Ramey <chet.ra...@case.edu> Date: Fri, 7 Feb 2020 14:58:55 -0500 Subject: [PATCH 1/2] problems restoring the history file are not signaled correctly to the calling application --- histfile.c | 2 ++ patchlevel | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/histfile.c b/histfile.c index 6c3adc9..8eb3496 100644 --- a/histfile.c +++ b/histfile.c @@ -620,6 +620,7 @@ history_truncate_file (const char *fname, int lines) if (rv != 0) { + rv = errno; if (tempname) unlink (tempname); history_lines_written_to_file = 0; @@ -767,6 +768,7 @@ mmap_error: if (rv != 0) { + rv = errno; if (tempname) unlink (tempname); history_lines_written_to_file = 0; diff --git a/patchlevel b/patchlevel index ce3e355..626a945 100644 --- a/patchlevel +++ b/patchlevel @@ -1,3 +1,3 @@ # Do not edit -- exists only for use by patch -3 +4 -- 2.17.1 From de1e4bcf64c0ff4b6c26da8bb569e2378bef090a Mon Sep 17 00:00:00 2001 From: Gary Lockyer <g...@catalyst.net.nz> Date: Tue, 8 Sep 2020 11:26:26 +1200 Subject: [PATCH 2/2] Fix segfault in rl_update_final If rl_display gets overridden i.e. for password entry init_line_structures is not called. See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=941326 Signed-off-by: Gary Lockyer <g...@catalyst.net.nz> --- display.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/display.c b/display.c index 4c6cc00..78e7a45 100644 --- a/display.c +++ b/display.c @@ -2959,6 +2959,15 @@ _rl_update_final (void) int full_lines, woff, botline_length; full_lines = 0; + + /* If line_structures_initialized has not been called + * there is nothing to do. This can happen if rl_redisplay is overridden + * for password entry or similar purposes. + */ + if (line_structures_initialized == 0) { + return; + } + /* If the cursor is the only thing on an otherwise-blank last line, compensate so we don't print an extra CRLF. */ if (_rl_vis_botlin && _rl_last_c_pos == 0 && -- 2.17.1
signature.asc
Description: OpenPGP digital signature