From: Peter Bray Date: Sat, 19 Nov 2016 13:01:59 +0000 (+1100) Subject: Set the variable "prog" before the first call to any routine using error reporting X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1400fc29a571bfdf181b2000afd0347a27a54b9c;p=fping.git Set the variable "prog" before the first call to any routine using error reporting Error reporting uses the variable "prog" which is null prior to obtaining a reference to argv[0]. The call to open_ping_socket() uses this on an error, such as the executable not being SUID or otherwise privileged invocation. Solaris 10 printf(3C) of "%s" on a null pointer causes a core dump. --- diff --git a/src/fping.c b/src/fping.c index c9a4981..fd424eb 100644 --- a/src/fping.c +++ b/src/fping.c @@ -365,6 +365,8 @@ int main( int argc, char **argv ) int tos = 0; HOST_ENTRY *cursor; + prog = argv[0]; + s = open_ping_socket(ping_data_size); if((uid = getuid())) { @@ -373,7 +375,6 @@ int main( int argc, char **argv ) perror("cannot setuid"); } - prog = argv[0]; ident = getpid() & 0xFFFF; verbose_flag = 1; backoff_flag = 1;