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.
pull/107/head
Peter Bray 8 years ago
parent 79ba8c9ae7
commit 1400fc29a5

@ -365,6 +365,8 @@ int main( int argc, char **argv )
int tos = 0; int tos = 0;
HOST_ENTRY *cursor; HOST_ENTRY *cursor;
prog = argv[0];
s = open_ping_socket(ping_data_size); s = open_ping_socket(ping_data_size);
if((uid = getuid())) { if((uid = getuid())) {
@ -373,7 +375,6 @@ int main( int argc, char **argv )
perror("cannot setuid"); perror("cannot setuid");
} }
prog = argv[0];
ident = getpid() & 0xFFFF; ident = getpid() & 0xFFFF;
verbose_flag = 1; verbose_flag = 1;
backoff_flag = 1; backoff_flag = 1;

Loading…
Cancel
Save