#12282: Fix strcmp() with NULL argument in termcap library
------------------------+---------------------------------------------------
   Reporter:  jdemeyer  |          Owner:  tbd                                  
       
       Type:  defect    |         Status:  needs_review                         
       
   Priority:  blocker   |      Milestone:  sage-4.8                             
       
  Component:  packages  |       Keywords:  sd35.5                               
       
Work_issues:            |       Upstream:  None of the above - read trac for 
reasoning.
   Reviewer:            |         Author:  Jeroen Demeyer                       
       
     Merged:            |   Dependencies:                                       
       
------------------------+---------------------------------------------------
Changes (by jdemeyer):

  * upstream:  Reported upstream. Little or no feedback. => None of the
               above - read trac for reasoning.


Old description:

> If the environment variable `TERMCAP` is set and `TERM` is not set, then
> calling `tgetent()` from the termcap library produces a Segmentation
> Fault because it calls `strcmp()` with a NULL argument.  Sage hits this
> problem because of readline, see #11970.
>
> To reproduce this issue: let `tgetent_test.c` be the file
> {{{
> #include <termcap.h>
> #include <stdlib.h>
> #include <stdio.h>
>
> int main(int argc, char** argv)
> {
>     char* buf = malloc(100000);
>     tgetent(buf, "dumb");
>     printf("Successful!\n");
> }
> }}}
>
> Now compile and link this with Sage's `libtermcap.a` (don't use
> `-ltermcap`, instead explicitly specify the path to the `libtermcap.a`
> file):
> {{{
> $ gcc tgetent_test.c local/lib/libtermcap.a -o tgetent_test
> }}}
>
> Run this with `TERMCAP` set but `TERM` unset:
> {{{
> $ unset TERM
> $ export TERMCAP="x"
> $ ./tgetent_test
> Segmentation fault
> }}}
>
> Reported upstream by email to the email address in `src/README`.
>
> '''Apply''':
> [http://boxen.math.washington.edu/home/jdemeyer/spkg/termcap-1.3.1.p2.spkg]

New description:

 If the environment variable `TERMCAP` is set and `TERM` is not set, then
 calling `tgetent()` from the termcap library produces a Segmentation Fault
 because it calls `strcmp()` with a NULL argument.  Sage hits this problem
 because of readline, see #11970.

 To reproduce this issue: let `tgetent_test.c` be the file
 {{{
 #include <termcap.h>
 #include <stdlib.h>
 #include <stdio.h>

 int main(int argc, char** argv)
 {
     char* buf = malloc(100000);
     tgetent(buf, "dumb");
     printf("Successful!\n");
 }
 }}}

 Now compile and link this with Sage's `libtermcap.a` (don't use
 `-ltermcap`, instead explicitly specify the path to the `libtermcap.a`
 file):
 {{{
 $ gcc tgetent_test.c local/lib/libtermcap.a -o tgetent_test
 }}}

 Run this with `TERMCAP` set but `TERM` unset:
 {{{
 $ unset TERM
 $ export TERMCAP="x"
 $ ./tgetent_test
 Segmentation fault
 }}}

 Not reported upstream because there is no known contact person nor bug
 report page.

 '''Apply''':
 [http://boxen.math.washington.edu/home/jdemeyer/spkg/termcap-1.3.1.p2.spkg]

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12282#comment:26>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to