screen 4.7.0 crashes on startup with rxvt defined by termcap (FreeBSD)

Marcin Cieslak <[email protected]> Mon, 28 Oct 2019 13:28:15 +0000
Newsgroups gmane.comp.gnu.screen.user
Message-ID <[email protected]>
Hello,

I have noticed that screen 4.7.0 crashes on my 11.x and 12.x FreeBSD
systems whenever TERM was set to "rxvt" or "rxvt-unicode-256color".

Preliminary analysis in the bug report:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241538

> Here's the rub: with TERM=xterm (or rxvt, for that matter), Km
> ("key_mouse", "Mouse event has occured") is not set (and therefore
> NULL), but InitTermcap() (termcap.c:230) happily tries to strdup()
> that, which gets us that segfault.

Looks like the culprit was:

commit fad4c29fd95d30639a67142066f623396fca8536
Author: Amadeusz SÂławiĂąski <[email protected]>
Date:   Sat Sep 7 17:58:50 2019 +0200

     Fix broken mouse after ncurses 6.1

     ncurses 6.1 changed kmous capability from "\e[M" to "\e[<". It seems to
     be done to signal that terminal supports sgr mouse mode. screen assumed
     that if kmous is set to "\e[M" it is on xterm compatible terminal
     anyway, so just dynamically detect which one is used and override
     relevant kmapdef.

     InitKeytab() is moved, so kmapdef[] can be overriden before
     initialization, as InitTermcap() needs to run first, as far as I can
     tell this should have no consequences.

     Signed-off-by: Amadeusz SÂławiĂąski <[email protected]>

A quick fix we have is to check for D_CKIM before strdup()ing it:

https://bugs.freebsd.org/bugzilla/attachment.cgi?id=208653&action=diff

saper
smime.p7s (application/pkcs7-signature, 3.6 KB) - not displayed