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
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.
Odd - I've run this with valgrind many times without noticing the bug (since the code is from October). thanks
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.
I added this change on Friday (20120622).
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.
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
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).
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
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.