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

 
 

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

Submitted by:  None
Submitted on:  Mon 23 Nov 2015 04:53:29 PM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: DuplicatePrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Component Version: 4.1Operating System: POSIX-Based
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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

This is a duplicate of bug #43434

Paul D. Smith <psmith>
Project 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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 23 Nov 2015 05:42:08 PM UTCpsmithStatusNone=>Duplicate
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1