From 1400fc29a571bfdf181b2000afd0347a27a54b9c Mon Sep 17 00:00:00 2001 From: Peter Bray Date: Sun, 20 Nov 2016 00:01:59 +1100 Subject: [PATCH] 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. --- src/fping.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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;