Bug 28369 - hard coded /bin/sh in gdb/ser-pipe.c
Summary: hard coded /bin/sh in gdb/ser-pipe.c
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 10.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-22 02:26 UTC by Maxim Cournoyer
Modified: 2021-09-30 22:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Maxim Cournoyer 2021-09-22 02:26:57 UTC
Hello, 

A hard coded instance of /bin/sh was discovered in GDB while running the test suite of ldc using Guix:

file: gdb/ser-pipe.c

static int
pipe_open (struct serial *scb, const char *name)
[...]
	}

      close_most_fds ();
      execl ("/bin/sh", "sh", "-c", name, (char *) 0);
      _exit (127);
    }

This contrasts with the rest of the code which carefully looks 'sh' from the PATH or SHELL variables.
Comment 2 Sourceware Commits 2021-09-30 22:19:39 UTC
The master branch has been updated by Sergio Durigan Junior <sergiodj@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=906e2b7664c5becfa3e10717a7d530e87fdab4ec

commit 906e2b7664c5becfa3e10717a7d530e87fdab4ec
Author: Sergio Durigan Junior <sergiodj@sergiodj.net>
Date:   Sat Sep 25 17:27:23 2021 -0400

    [PR gdb/28369] Use get_shell on gdb/ser-pipe.c
    
    PR gdb/28369 reports that gdb/ser-pipe.c has an 'execl' function call
    with a hard-coded "/bin/sh" as its argument.  We've had 'get_shell'
    for a while now, which is conscious about the SHELL environment and a
    better alternative to always calling "/bin/sh".
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28369
Comment 3 Sergio Durigan Junior 2021-09-30 22:54:15 UTC
This has been fixed.