libedit: fix crash if prompt contains invalid utf-8

This commit is contained in:
PulkoMandy
2022-04-10 22:16:22 +02:00
parent 5439f25322
commit d9117df2fd
2 changed files with 39 additions and 11 deletions

View File

@@ -6,7 +6,7 @@ found in GNU Readline."
HOMEPAGE="http://thrysoee.dk/editline/"
COPYRIGHT="1992-2021 The NetBSD Foundation, Inc."
LICENSE="BSD (3-clause)"
REVISION="1"
REVISION="2"
SOURCE_URI="http://thrysoee.dk/editline/libedit-${portVersion/_/-}.tar.gz"
SOURCE_DIR="libedit-${portVersion/_/-}"
CHECKSUM_SHA256="6792a6a992050762edcca28ff3318cdb7de37dccf7bc30db59fcd7017eed13c5"

View File

@@ -1,11 +1,11 @@
From a68cec6b9b23f1632f14e74e86778ff248ecc8cd Mon Sep 17 00:00:00 2001
From 16e6736e5ab6bc363ef932c11867287f3d218845 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Wed, 26 Nov 2014 16:48:13 +0000
Subject: Haiku patch
diff --git a/configure.ac b/configure.ac
index 013fb62..5180019 100644
index 72a41f9..c03c84d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,7 +72,7 @@ AM_CONDITIONAL(ENABLE_EXAMPLES, [test "$enable_examples" = "yes"])
@@ -18,10 +18,10 @@ index 013fb62..5180019 100644
AC_CHECK_HEADER([ncurses.h], [],
[AC_CHECK_HEADER([curses.h], [],
diff --git a/src/editline/readline.h b/src/editline/readline.h
index 7e53f41..64a5fb3 100644
index e9f941a..b0db9e0 100644
--- a/src/editline/readline.h
+++ b/src/editline/readline.h
@@ -76,7 +76,7 @@ typedef KEYMAP_ENTRY *Keymap;
@@ -77,7 +77,7 @@ typedef KEYMAP_ENTRY *Keymap;
#ifndef CTRL
#include <sys/ioctl.h>
@@ -31,7 +31,7 @@ index 7e53f41..64a5fb3 100644
#endif
#ifndef CTRL
diff --git a/src/vis.c b/src/vis.c
index ce66205..283cf38 100644
index a454874..9981ac2 100644
--- a/src/vis.c
+++ b/src/vis.c
@@ -75,6 +75,10 @@ __FBSDID("$FreeBSD$");
@@ -49,7 +49,7 @@ index ce66205..283cf38 100644
2.30.2
From 95fc6ef00932e10efe45dbc379249d64cfc31d14 Mon Sep 17 00:00:00 2001
From 993bc4d5d290e6770d5046794659fac47c2ea367 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Wed, 26 Nov 2014 16:55:47 +0000
Subject: define NBBY
@@ -72,7 +72,7 @@ index d2bcf11..44dca9d 100644
2.30.2
From 70f3f89ddea86c9b0307ec7f717d6cde4c8fc16d Mon Sep 17 00:00:00 2001
From 7de9dc213a7b3a81b2c43e5af0df60ae6ee4d620 Mon Sep 17 00:00:00 2001
From: fbrosson <fbrosson@localhost>
Date: Thu, 1 Feb 2018 11:05:59 +0000
Subject: gcc2 support.
@@ -101,14 +101,14 @@ index 19ce1c1..2c88b28 100644
2.30.2
From eaa32eed8c5a2f5709a3c71d2e6baf346775e46e Mon Sep 17 00:00:00 2001
From 1ea2455e8f597149a1612a8a0fab70245cf58a2b Mon Sep 17 00:00:00 2001
From: begasus <begasus@gmail.com>
Date: Sat, 1 May 2021 09:40:38 +0000
Subject: Another gcc2 patch
diff --git a/src/filecomplete.c b/src/filecomplete.c
index baca190..a49ad41 100644
index 84ae508..51501d6 100644
--- a/src/filecomplete.c
+++ b/src/filecomplete.c
@@ -707,6 +707,7 @@ fn_complete2(EditLine *el,
@@ -119,7 +119,7 @@ index baca190..a49ad41 100644
int i;
size_t matches_num, maxlen, match_len, match_display=1;
int single_match = matches[2] == NULL &&
@@ -813,6 +814,7 @@ fn_complete2(EditLine *el,
@@ -814,6 +815,7 @@ out2:
out:
el_free(temp);
return retval;
@@ -130,3 +130,31 @@ index baca190..a49ad41 100644
--
2.30.2
From e86be215341d8a867f9f005ee66e389a8b4baf12 Mon Sep 17 00:00:00 2001
From: PulkoMandy <pulkomandy@pulkomandy.tk>
Date: Sun, 10 Apr 2022 22:10:17 +0200
Subject: Fix NULL pointer dereference if the prompt contains invalid UTF8
diff --git a/src/prompt.c b/src/prompt.c
index 026a746..bbad962 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -96,6 +96,13 @@ prompt_print(EditLine *el, int op)
p = ct_decode_string((char *)(void *)(*elp->p_func)(el),
&el->el_scratch);
+ if (!p) {
+ if (op == EL_PROMPT)
+ p = prompt_default(el);
+ else
+ p = prompt_default_r(el);
+ }
+
for (; *p; p++) {
if (elp->p_ignore == *p) {
wchar_t *litstart = ++p;
--
2.30.2