Skip to contentSkip to conversation

package/readline: add upstream patch to fix crash with invalid locale specification

PATCH Applied Peter Seiderer 4 participants 5 messages Mar 22, 2023 – May 2, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/readline: add upstream patch to fix crash with invalid locale specification

Add upstream patch to fix crash with invalid locale specification (see [1] for details).

Fixes:

- https://bugs.busybox.net/show_bug.cgi?id=15456

[1] https://lists.gnu.org/archive/html/bug-readline/2022-10/msg00002.html

---
 ...ch-1-fix-crash-when-readline-is-star.patch | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch
package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch new file +41 -0
new file mode 100644
index 0000000000..b0f784b8ba
@@ -0,0 +1,41 @@
+From b8d91eab12603fa88e095248855f5f772d182d05 Mon Sep 17 00:00:00 2001
+From: Chet Ramey <[email protected]>
+Date: Wed, 5 Oct 2022 10:41:16 -0400
+Subject: [PATCH] Readline-8.2 patch 1: fix crash when readline is started with
+ an invalid locale specification
+
+[Upstream: https://git.savannah.gnu.org/cgit/readline.git/patch/?id=7274faabe97ce53d6b464272d7e6ab6c1392837b
+ Stripped unrelated ._.gitignore change]
+Signed-off-by: Peter Seiderer <[email protected]>
+---
+ nls.c      | 4 ++++
+ patchlevel | 2 +-
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/nls.c b/nls.c
+index 5c6a13b..8c027d6 100644
+--- a/nls.c
++++ b/nls.c
+@@ -141,6 +141,10 @@ _rl_init_locale (void)
+   if (lspec == 0)
+     lspec = "";
+   ret = setlocale (LC_CTYPE, lspec);	/* ok, since it does not change locale */
++  if (ret == 0 || *ret == 0)
++    ret = setlocale (LC_CTYPE, (char *)NULL);
++  if (ret == 0 || *ret == 0)
++    ret = RL_DEFAULT_LOCALE;
+ #else
+   ret = (lspec == 0 || *lspec == 0) ? RL_DEFAULT_LOCALE : lspec;
+ #endif
+diff --git a/patchlevel b/patchlevel
+index d8c9df7..fdf4740 100644
+--- a/patchlevel
++++ b/patchlevel
+@@ -1,3 +1,3 @@
+ # Do not edit -- exists only for use by patch
+ 
+-0
++1
+-- 
+2.39.2
+
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Tested-by on v1 1/1
#1 lore raw
Quoted 10 lines · Peter Seiderer

Add upstream patch to fix crash with invalid locale specification (see [1] for details).

Fixes:

- https://bugs.busybox.net/show_bug.cgi?id=15456

[1] https://lists.gnu.org/archive/html/bug-readline/2022-10/msg00002.html

This fixes a crash seen with bluetoothctl here.

Ideally this should be applied to to LTS Buildroot 2023.02 too.

--
Stefan

Quoted 47 lines
---
 ...ch-1-fix-crash-when-readline-is-star.patch | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644

package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch

diff --git a/package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch b/package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch new file mode 100644
index 0000000000..b0f784b8ba
--- /dev/null
+++
b/package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch

package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch new file +7 -0
@@ -0,0 +1,41 @@
+From b8d91eab12603fa88e095248855f5f772d182d05 Mon Sep 17 00:00:00 2001
+From: Chet Ramey <[email protected]>
+Date: Wed, 5 Oct 2022 10:41:16 -0400
+Subject: [PATCH] Readline-8.2 patch 1: fix crash when readline is started with
+ an invalid locale specification
+
+[Upstream:

https://git.savannah.gnu.org/cgit/readline.git/patch/?id=7274faabe97ce53d6b464272d7e6ab6c1392837b
+ Stripped unrelated ._.gitignore change]

package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch new file +23 -0
+Signed-off-by: Peter Seiderer <[email protected]>
+---
+ nls.c      | 4 ++++
+ patchlevel | 2 +-
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/nls.c b/nls.c
+index 5c6a13b..8c027d6 100644
+--- a/nls.c
++++ b/nls.c
+@@ -141,6 +141,10 @@ _rl_init_locale (void)
+   if (lspec == 0)
+     lspec = "";
+   ret = setlocale (LC_CTYPE, lspec);	/* ok, since it does not change locale */
++  if (ret == 0 || *ret == 0)
++    ret = setlocale (LC_CTYPE, (char *)NULL);
++  if (ret == 0 || *ret == 0)
++    ret = RL_DEFAULT_LOCALE;
+ #else
+   ret = (lspec == 0 || *lspec == 0) ? RL_DEFAULT_LOCALE : lspec;
+ #endif
+diff --git a/patchlevel b/patchlevel
+index d8c9df7..fdf4740 100644

package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch line 41

Quoted 10 lines
package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch new file +10 -0
+--- a/patchlevel
++++ b/patchlevel
+@@ -1,3 +1,3 @@
+ # Do not edit -- exists only for use by patch
+ 
+-0
++1
+-- 
+2.39.2
+

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw

Stefan, All,

+Peter K, for backport.

On 2023-04-24 19:34 +0200, Stefan Agner spake thusly:

Quoted 6 lines · Peter Seiderer
Quoted 5 lines

Add upstream patch to fix crash with invalid locale specification (see [1] for details).

Fixes:

Quoted 7 lines
Quoted 5 lines

- https://bugs.busybox.net/show_bug.cgi?id=15456

[1] https://lists.gnu.org/archive/html/bug-readline/2022-10/msg00002.html

This fixes a crash seen with bluetoothctl here.

And it also makes bash segfault when there is no locale set, and none available (it seems). I'll try to cook up a runtime test for bash that catches the no-locale setup.

Quoted 2 lines

Ideally this should be applied to to LTS Buildroot 2023.02 too.

Yes.

Regards,
Yann E. MORIN.

Quoted 64 lines

--
Stefan

Quoted 47 lines
---
 ...ch-1-fix-crash-when-readline-is-star.patch | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644

package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch

diff --git a/package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch b/package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch new file mode 100644
index 0000000000..b0f784b8ba
--- /dev/null
+++
b/package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch

package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch new file +7 -0
@@ -0,0 +1,41 @@
+From b8d91eab12603fa88e095248855f5f772d182d05 Mon Sep 17 00:00:00 2001
+From: Chet Ramey <[email protected]>
+Date: Wed, 5 Oct 2022 10:41:16 -0400
+Subject: [PATCH] Readline-8.2 patch 1: fix crash when readline is started with
+ an invalid locale specification
+
+[Upstream:

https://git.savannah.gnu.org/cgit/readline.git/patch/?id=7274faabe97ce53d6b464272d7e6ab6c1392837b
+ Stripped unrelated ._.gitignore change]

package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch new file +23 -0
+Signed-off-by: Peter Seiderer <[email protected]>
+---
+ nls.c      | 4 ++++
+ patchlevel | 2 +-
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/nls.c b/nls.c
+index 5c6a13b..8c027d6 100644
+--- a/nls.c
++++ b/nls.c
+@@ -141,6 +141,10 @@ _rl_init_locale (void)
+   if (lspec == 0)
+     lspec = "";
+   ret = setlocale (LC_CTYPE, lspec);	/* ok, since it does not change locale */
++  if (ret == 0 || *ret == 0)
++    ret = setlocale (LC_CTYPE, (char *)NULL);
++  if (ret == 0 || *ret == 0)
++    ret = RL_DEFAULT_LOCALE;
+ #else
+   ret = (lspec == 0 || *lspec == 0) ? RL_DEFAULT_LOCALE : lspec;
+ #endif
+diff --git a/patchlevel b/patchlevel
+index d8c9df7..fdf4740 100644

package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch line 41

Quoted 10 lines
package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch new file +10 -0
+--- a/patchlevel
++++ b/patchlevel
+@@ -1,3 +1,3 @@
+ # Do not edit -- exists only for use by patch
+ 
+-0
++1
+-- 
+2.39.2
+

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw
In reply to Stefan Agner
Quoted 12 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stefan" == Stefan Agner <[email protected]> writes:

Quoted 9 lines · Peter Seiderer

Add upstream patch to fix crash with invalid locale specification (see [1] for details).

Fixes:

- https://bugs.busybox.net/show_bug.cgi?id=15456

[1] https://lists.gnu.org/archive/html/bug-readline/2022-10/msg00002.html

Quoted 7 lines
Quoted 1 line

This fixes a crash seen with bluetoothctl here.

Ideally this should be applied to to LTS Buildroot 2023.02 too.

Committed to 2023.02.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw
In reply to Peter Seiderer

Peter, All,

On 2023-03-22 17:25 +0100, Peter Seiderer spake thusly:

Quoted 10 lines

Add upstream patch to fix crash with invalid locale specification (see [1] for details).

Fixes:

- https://bugs.busybox.net/show_bug.cgi?id=15456

[1] https://lists.gnu.org/archive/html/bug-readline/2022-10/msg00002.html

Applied to master, thanks.

Regards,
Yann E. MORIN.

Quoted 59 lines
---
 ...ch-1-fix-crash-when-readline-is-star.patch | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch
package/readline/0002-Readline-8.2-patch-1-fix-crash-when-readline-is-star.patch new file +41 -0
new file mode 100644
index 0000000000..b0f784b8ba
@@ -0,0 +1,41 @@
+From b8d91eab12603fa88e095248855f5f772d182d05 Mon Sep 17 00:00:00 2001
+From: Chet Ramey <[email protected]>
+Date: Wed, 5 Oct 2022 10:41:16 -0400
+Subject: [PATCH] Readline-8.2 patch 1: fix crash when readline is started with
+ an invalid locale specification
+
+[Upstream: https://git.savannah.gnu.org/cgit/readline.git/patch/?id=7274faabe97ce53d6b464272d7e6ab6c1392837b
+ Stripped unrelated ._.gitignore change]
+Signed-off-by: Peter Seiderer <[email protected]>
+---
+ nls.c      | 4 ++++
+ patchlevel | 2 +-
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/nls.c b/nls.c
+index 5c6a13b..8c027d6 100644
+--- a/nls.c
++++ b/nls.c
+@@ -141,6 +141,10 @@ _rl_init_locale (void)
+   if (lspec == 0)
+     lspec = "";
+   ret = setlocale (LC_CTYPE, lspec);	/* ok, since it does not change locale */
++  if (ret == 0 || *ret == 0)
++    ret = setlocale (LC_CTYPE, (char *)NULL);
++  if (ret == 0 || *ret == 0)
++    ret = RL_DEFAULT_LOCALE;
+ #else
+   ret = (lspec == 0 || *lspec == 0) ? RL_DEFAULT_LOCALE : lspec;
+ #endif
+diff --git a/patchlevel b/patchlevel
+index d8c9df7..fdf4740 100644
+--- a/patchlevel
++++ b/patchlevel
+@@ -1,3 +1,3 @@
+ # Do not edit -- exists only for use by patch
+ 
+-0
++1
+-- 
+2.39.2
+
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot