Overview
| Artifact ID: | e70fbc08a0681f1d1009b267ab20e7b4af2b136a04190a7f4c87fde61fa591fd |
|---|---|
| Ticket: | 0ac9d06895f000b3c83fcb6b14940acc79f11122
Don't call getsockname(2) in Tcl_MakeFileChannel(3) unless absolutely necessary |
| User & Date: | stu on 2018-06-07 06:25:47 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/html"
- comment changed to:
Tcl_MakeFileChannel(3) checks if the given fd is a tty or a socket before assuming it's a file. <br> If there are <a href="https://man.openbsd.org/pledge">pledge(2)</a>es in effect that are restricting the usage of network functions then Tcl_MakeFileChannel will segfault when it tries to use getsockname(2) to check if the fd is a socket. <br> An important time when this happens is when tclsh is fed a script on stdin: tclsh will immediately segfault. <br> By using fstat(2) to first check if the fd is a socket, a call to getsockname might be avoided. <br> This may have security implications. <br><br> Attached is a patch. <br> The patch has the nice side effect of putting all the socket bits in one place. <br><br> Here is a test program: <pre> #include <unistd.h> #define TCLSH "/usr/local/bin/tclsh" int main (int argc, char *argv[]) { char *a[] = { TCLSH, NULL }; char *e[] = { NULL }; #ifdef DNS pledge(NULL, "stdio rpath getpw dns"); #else # ifdef INET pledge(NULL, "stdio rpath getpw inet"); # else pledge(NULL, "stdio rpath getpw"); # endif #endif execve(TCLSH, a, e); return 0; } </pre> Build with no -D's: <pre> $ cc -o tpl tpl.c $ echo 'puts moo' | ./tpl Abort trap (core dumped) </pre> Build with either -DINET or -DDNS: <pre> $ cc -o tpl tpl.c -DINET $ echo 'puts moo' | ./tpl moo </pre> - foundin changed to: "8.6.*"
- is_private changed to: "0"
- login: "stu"
- priority changed to: "5 Medium"
- private_contact changed to: "702b65e835b7b4b4720d6e9d37fc582f82909394"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "stu"
- subsystem changed to: "38. Init - Library - Autoload"
- title changed to:
Don't call getsockname(2) in Tcl_MakeFileChannel(3) unless absolutely necessary
- type changed to: "RFE"