bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Ping crash because of wrong initializiation


From: Moritz Schulte
Subject: Ping crash because of wrong initializiation
Date: Fri, 09 Aug 2002 19:26:47 +0200
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.2

Hi,

ping from CVS crashes, because while parsing the command line
arguments, ping already tries to manipulate the ping structure - but
that structurs is intialized after the parsing.

2002-08-09 Moritz Schulte <address@hidden>

        * ping.c (main): Moved ping initialization to before the parsing
        of the command line, because the parsing of some arguments expects
        an already initialized ping structure.

--- ping.c.orig Fri Aug  9 19:05:58 2002
+++ ping.c      Fri Aug  9 19:08:05 2002
@@ -112,6 +112,14 @@
   u_char *patptr = NULL;
   int is_root = getuid () == 0;
 
+  ping = ping_init (ICMP_ECHO, getpid ());
+  if (ping == NULL)
+    {
+      fprintf (stderr, "can't init ping: %s\n", strerror (errno));
+      exit (1);
+    }
+  ping_set_sockopt (ping, SO_BROADCAST, (char *)&one, sizeof (one));
+
   /* Parse command line */
   while ((c = getopt_long (argc, argv, short_options, long_options, NULL))
         != EOF)
@@ -224,14 +232,6 @@
 
   init_data_buffer (patptr, pattern_len);
 
-  ping = ping_init (ICMP_ECHO, getpid ());
-  if (ping == NULL)
-    {
-      fprintf (stderr, "can't init ping: %s\n", strerror (errno));
-      exit (1);
-    }
-  ping_set_sockopt (ping, SO_BROADCAST, (char *)&one, sizeof (one));
-  
   /* Reset root privileges */
   setuid (getuid ());
   

                moritz
-- 
address@hidden - http://duesseldorf.ccc.de/~moritz/
GPG fingerprint = 3A14 3923 15BE FD57 FC06  B501 0841 2D7B 6F98 4199



reply via email to

[Prev in Thread] Current Thread [Next in Thread]