valgrind reports:
Syscall param write(buf) points to uninitialised byte(s)
In this case, it is a false positive, but adding this single memset at
attach start-up means the program is now clean when run with "valgrind
--trace-children=yes dtach -c ...", which can make future debugging
easier.
attach.c did not correctly handle a read from stdin when read returned
an error. The code assigned the return value of read to pkt.len (an
unsigned char) before checking the value. This prevented the error check
from working correctly, since an unsigned integer can never be < 0.
A packet with an invalid length was then sent to the master, which then
sent 255 bytes of garbage to the program.
Fix the bug in attach.c and the unchecked packet length bug in master.c.
Report and initial patch by Enrico Scholz.
paranoid about this, and only remove the specified file if connect says
the connection was refused and stat says the file is a socket.
Also dtach -A now only tries to create the socket if the connection was
refused or the socket did not exist, instead of on any random error as
before.
exiting silently.
Also make sure the master process waits until the client attaches when using
the -A and -c modes, so that the error message has a chance of being seen.