Bug#890769: libslang2: incompatible with the extended terminfo format in ncurses 6.1

2018-03-05 Thread Egmont Koblinger
Hi,

FYI: slang-2.3.2 is out now.

cheers,
e.

On Wed, Feb 21, 2018 at 3:17 PM, Egmont Koblinger  wrote:
> Hi Sven & Alastair,
>
> Thanks a lot for this bugreport and the quick fix!
>
> I've asked Slang's author to release version 2.3.2 in the near future
> to officially fix this issue, and he agreed to do so at the end of
> this month. See [1].
>
> If that indeed happens, upgrading to 2.3.2 would be a cleaner,
> official fix, allowing you to drop the patch. Let's keep an eye on it.
>
> Cheers,
> egmont
>
> [1] http://lists.jedsoft.org/lists/slang-users/2018/000.html



Bug#890769: libslang2: incompatible with the extended terminfo format in ncurses 6.1

2018-02-21 Thread Egmont Koblinger
Hi Sven & Alastair,

Thanks a lot for this bugreport and the quick fix!

I've asked Slang's author to release version 2.3.2 in the near future
to officially fix this issue, and he agreed to do so at the end of
this month. See [1].

If that indeed happens, upgrading to 2.3.2 would be a cleaner,
official fix, allowing you to drop the patch. Let's keep an eye on it.

Cheers,
egmont

[1] http://lists.jedsoft.org/lists/slang-users/2018/000.html



Bug#890769: libslang2: incompatible with the extended terminfo format in ncurses 6.1

2018-02-18 Thread Sven Joachim
Control: tags -1 + patch

On 2018-02-18 18:07 +0100, Sven Joachim wrote:

> Package: libslang2
> Version: 2.3.1a-2
> Severity: important
>
> In ncurses 6.1, an extended terminfo format has been introduced with
> 32-bit database entries.  It is automatically enabled if the tinfo
> library is configured with --with-abi-version=6 and --enable-widec.
> The Debian package currently does neither (see #230990 on the former),
> but I would like to enable this new format soon.
>
> The slang library, as of version 2.3.1a, is not compatible with these
> new database entries, which causes applications to misbehave or even
> fail to start.  This has been noticed in other distributions which have
> enabled the new terminfo format:
>
> https://bugs.archlinux.org/task/57300
> https://bugzilla.opensuse.org/show_bug.cgi?id=1079543
> [...]
> It looks like upstream has addressed this problem in version pre2.3.2-19
> ("Added support for the new ncurses 32-bit terminfo database entries."),
> I will look if I can extract a patch from their git repository.

That turned out to to be pleasantly easy.  I only had to remove the
irrelevant hunks for changes.txt and src/slang.h to get the patch
applied, and from a quick test with Midnight Commander and whiptail it
seems to work just fine. :-)

Attached is the patch, ready to be dropped into debian/patches.  Don't
forget to update the series file to actually apply it.

Cheers,
   Sven

From 6dd5ade9a97b52ace4ac033779a6d3c1c51db4d1 Mon Sep 17 00:00:00 2001
From: "John E. Davis" 
Date: Tue, 30 Jan 2018 04:04:17 -0500
Subject: [PATCH 1/1] pre2.3.2-19: Added support for the new ncurses 32-bit
 terminfo database entries.

---
 src/sltermin.c |   76 +++--
 src/untic.c|5 ++-
 2 files changed, 61 insertions(+), 20 deletions(-)

--- a/src/sltermin.c
+++ b/src/sltermin.c
@@ -33,6 +33,11 @@ USA.
  * term(4) man page on an SGI.
  */
 
+/* The ncurses terminfo binary files come in two flavors: A legacy
+ * format that uses 16 bit integers in the number-section, and a new
+ * 32 bit format (nurses 6, from 2018).
+ */
+
 /* Short integers are stored in two 8-bit bytes.  The first byte contains
  * the least significant 8 bits of the value, and the second byte contains
  * the most significant 8 bits.  (Thus, the value represented is
@@ -43,7 +48,7 @@ USA.
  * source and also is to be considered missing.
  */
 
-static int make_integer (unsigned char *buf)
+static int make_integer16 (unsigned char *buf)
 {
register int lo, hi;
lo = (int) *buf++; hi = (int) *buf;
@@ -55,6 +60,20 @@ static int make_integer (unsigned char *
return lo + 256 * hi;
 }
 
+static int make_integer32 (unsigned char *buf)
+{
+   unsigned int u;
+   int i;
+
+   u = (unsigned int)buf[0];
+   u |= ((unsigned int)buf[1])<<8;
+   u |= ((unsigned int)buf[2])<<16;
+   u |= ((unsigned int)buf[3])<<24;
+
+   i = (int)u;
+   return i;
+}
+
 /*
  * The compiled file is created from the source file descriptions of the
  * terminals (see the -I option of infocmp) by using the terminfo compiler,
@@ -64,14 +83,15 @@ static int make_integer (unsigned char *
  *
  * The header section begins the file.  This section contains six short
  * integers in the format described below.  These integers are (1) the magic
- * number (octal 0432); (2) the size, in bytes, of the names section; (3)
- * the number of bytes in the boolean section; (4) the number of short
- * integers in the numbers section; (5) the number of offsets (short
+ * number (legacy:0432, 01036:32 but); (2) the size, in bytes, of the names section; (3)
+ * the number of bytes in the boolean section; (4) the number of integers
+ * in the numbers section; (5) the number of offsets (short
  * integers) in the strings section; (6) the size, in bytes, of the string
  * table.
  */
 
-#define MAGIC 0432
+#define MAGIC_LEGACY 0432
+#define MAGIC_32BIT 01036
 
 /* In this structure, all char * fields are malloced EXCEPT if the
  * structure is SLTERMCAP.  In that case, only terminal_names is malloced
@@ -91,6 +111,8 @@ struct _pSLterminfo_Type
 
unsigned int num_numbers;
unsigned char *numbers;
+   unsigned int sizeof_number;
+   int (*make_integer)(unsigned char *);
 
unsigned int num_string_offsets;
unsigned char *string_offsets;
@@ -109,6 +131,7 @@ static FILE *open_terminfo (char *file,
 {
FILE *fp;
unsigned char buf[12];
+   int magic;
 
/* Alan Cox reported a security problem here if the application using the
 * library is setuid.  So, I need to make sure open the file as a normal
@@ -122,19 +145,34 @@ static FILE *open_terminfo (char *file,
fp = fopen (file, "rb");
if (fp == NULL) return NULL;
 
-   if ((12 == fread ((char *) buf, 1, 12, fp) && (MAGIC == make_integer (buf
+   if (12 != fread ((char *)buf, 1, 12, fp))
+ {
+	(void) fclose(fp);
+	return NULL;
+ }
+   magic = make_integer16(buf);
+   if (magic == MAGIC_LEGACY)
+ {
+	

Bug#890769: libslang2: incompatible with the extended terminfo format in ncurses 6.1

2018-02-18 Thread Sven Joachim
Package: libslang2
Version: 2.3.1a-2
Severity: important

In ncurses 6.1, an extended terminfo format has been introduced with
32-bit database entries.  It is automatically enabled if the tinfo
library is configured with --with-abi-version=6 and --enable-widec.
The Debian package currently does neither (see #230990 on the former),
but I would like to enable this new format soon.

The slang library, as of version 2.3.1a, is not compatible with these
new database entries, which causes applications to misbehave or even
fail to start.  This has been noticed in other distributions which have
enabled the new terminfo format:

https://bugs.archlinux.org/task/57300
https://bugzilla.opensuse.org/show_bug.cgi?id=1079543

My own experiments with Midnight Commander showed the following:

- with TERM=xterm-256color (the default in most terminal emulators these
  days), mc starts in black, and the arrow keys don't work.

- with TERM=screen-256color (used by many screen users), mc does not
  start at all:

,
| $ TERM=screen-256color mc
| Unknown terminal: screen-256color
| Check the TERM environment variable.
| Also make sure that the terminal is defined in the terminfo database.
| Alternatively, set the TERMCAP environment variable to the desired
| termcap entry.
`

To reproduce the problem, do one of the following:

- unpack the attached terminfo files, overwriting the ones on the system:
  # tar -C /lib -vxf terminfo.tar.gz

- build ncurses from the branch at
  https://salsa.debian.org/joachim-guest/ncurses/tree/wide-terminfo,
  e.g. with "dpkg-buildpackage -A", and install the resulting
  ncurses-base_6.1+20180210-1_all.deb.

In either case, reinstall ncurses-base from the Debian repository when
you're done to undo the changes.


It looks like upstream has addressed this problem in version pre2.3.2-19
("Added support for the new ncurses 32-bit terminfo database entries."),
I will look if I can extract a patch from their git repository.


-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (101, 'experimental')
Architecture: i386 (x86_64)
Foreign Architectures: amd64

Kernel: Linux 4.15.4-nouveau (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), 
LANGUAGE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libslang2 depends on:
ii  libc6  2.26-6

libslang2 recommends no packages.

libslang2 suggests no packages.

-- no debconf information



terminfo.tar.gz
Description: application/gzip


signature.asc
Description: PGP signature