bugmake - Bugs: bug #46502, make SEGV due to isatty()...

 
 

bug #46502: make SEGV due to isatty() ttyname() bug in docker container

Submitter:  None
Submitted:  Mon 23 Nov 2015 04:53:29 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Duplicate Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.1 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 23 Nov 2015 05:42:08 PM UTC, comment #1: 

This is a duplicate of bug #43434

Paul D. Smith <psmith>
Group administrator
Mon 23 Nov 2015 04:53:29 PM UTC, original submission:  

A bug in docker has uncovered what I consider to be a bug in make.  If you run make inside an exec'd shell (docker exec -ti "testmake" /bin/bash) it will SEGV because isatty(fileno(stdout)) returns 1 but ttyname(fileno(stdout)) returns NULL.

#0  strlen () at ../sysdeps/x86_64/strlen.S:106
#1  0x00007ffff789982e in __GI___strdup (s=0x0) at strdup.c:41
#2  0x0000000000417b19 in xstrdup (ptr=ptr@entry=0x0) at /root/workspace/dev_tools/stage1/source/make-4.1/misc.c:259
#3  0x000000000042274c in define_variable_in_set (name=name@entry=0x428dcb "MAKE_TERMOUT", length=length@entry=12, value=0x0,
    origin=origin@entry=o_default, recursive=recursive@entry=0, set=set@entry=0x634040 <global_variable_set>, flocp=flocp@entry=0x0)
    at /root/workspace/dev_tools/stage1/source/make-4.1/variable.c:243
#4  0x0000000000406ac0 in main (argc=<optimized out>, argv=<optimized out>, envp=0x7fffffffe718)
    at /root/workspace/dev_tools/stage1/source/make-4.1/main.c:1404

The following code in main.c should check the return value of TTYNAME (which according to man pages can return NULL as an exception condition) instead of blindly passing the pointer:

main.c:1401
#ifdef HAVE_ISATTY
    if (isatty (fileno (stdout)))
      if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMOUT")))
        define_variable_cname ("MAKE_TERMOUT", TTYNAME (fileno (stdout)),
                               o_default, 0)->export = v_export;

    if (isatty (fileno (stderr)))
      if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMERR")))
        define_variable_cname ("MAKE_TERMERR", TTYNAME (fileno (stderr)),
                               o_default, 0)->export = v_export;
#endif

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-11-23 psmith StatusNone Duplicate
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code