Bug 831366 - ncurses caches the TERMINFO variable incorrectly
Summary: ncurses caches the TERMINFO variable incorrectly
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: ncurses
Version: 17
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Lichvar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-06-12 21:17 UTC by Philippe Troin
Modified: 2012-12-20 16:21 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-12-20 16:21:50 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Test program (528 bytes, text/x-csrc)
2012-06-12 21:17 UTC, Philippe Troin
no flags Details
Patch curing the issue (1.06 KB, patch)
2012-06-12 21:20 UTC, Philippe Troin
no flags Details | Diff

Description Philippe Troin 2012-06-12 21:17:07 UTC
Created attachment 591287 [details]
Test program

Description of problem:
Ncurses caches the TERMINFO variable incorrectly.
The problem manifests itself when processes change the TERMINFO while a curses session is ongoing.

Version-Release number of selected component (if applicable):
ncurses-5.9-4.20120204.fc17

How reproducible:
Always

Steps to Reproduce:
1. mkdir ~/terminfo
2. echo "someterm,use=xterm" > someterm
3. TERMINFO=~/terminfo tic someterm
4. Compile the attached test program:
    gcc -Wall -o cursestest cursestest.c -ltinfo
5. Run it:
    ./cursestest ~/terminfo

Actual results:
No/inherited TERMINFO
xterm 1
someterm 0
TERMINFO=/home/phil/terminfo
xterm 1
someterm 0

Expected results:
No/inherited TERMINFO
xterm 1
someterm 0
TERMINFO=/home/phil/terminfo
xterm 1
someterm 1

Comment 1 Philippe Troin 2012-06-12 21:20:19 UTC
Created attachment 591288 [details]
Patch curing the issue

This patch fixes the problem for ncurses-5.9-20120204.

Please note that the patch's first hunk fixes a memory allocation problem (the strings returned by getenv() are stored and then freed with free() which is a big no-no), while the second and third hunks actually fix the issue.

Phil.

Comment 2 Thomas E. Dickey 2012-06-20 01:05:23 UTC
Odd - I've run this with valgrind many times without noticing the bug
(since the code is from October).  thanks

Comment 3 Philippe Troin 2012-06-20 15:35:15 UTC
The faulty code can only trigger if TERMINFO changes during the lifetime of a process, which is not very common.
I happen to do that in my login scripts, to change terminal features transparently (I hate the alternate screen used by vi/less/etc with a passion which I turn-off automagically be defining an alternate terminal derived from the current one), but that's unlikely to be common.

I've also noticed (and maybe I should open another bug for that) that the .spec does NOT clear TERMINFO before running and if you happen to have TERMINFO defined when running rpmbuild, the package build will fail as the install target will try to install terminal definitions in "$DESTDIR$TERMINFO".
You may want to clear (the new) TERMINFO_PATH (sp?) and friends as well.

Phil.

Comment 4 Thomas E. Dickey 2012-06-27 11:57:54 UTC
I added this change on Friday (20120622).

Comment 5 Thomas E. Dickey 2012-06-27 12:07:09 UTC
For what it's worth, I wrap my package builds in a script that limits
the environment, leaving only TMPDIR, USER, PATH, HOME and LOGNAME.
I would assume that packagers do the same, more or less.

Comment 6 Fedora Update System 2012-10-15 17:26:15 UTC
ncurses-5.9-6.20121013.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/ncurses-5.9-6.20121013.fc18

Comment 7 Fedora Update System 2012-10-16 01:24:48 UTC
Package ncurses-5.9-6.20121013.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing ncurses-5.9-6.20121013.fc18'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-16193/ncurses-5.9-6.20121013.fc18
then log in and leave karma (feedback).

Comment 8 Fedora Update System 2012-10-18 09:52:14 UTC
ncurses-5.9-7.20121017.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/ncurses-5.9-7.20121017.fc18

Comment 9 Fedora Update System 2012-12-20 16:21:55 UTC
ncurses-5.9-6.20121013.fc18 has been pushed to the Fedora 18 obsolete repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.