Compilation problems and bugs in wackamole 2.1.1

Richard Lloyd <[email protected]> Tue, 7 Sep 2004 14:06:00 +0100 (BST)
Newsgroups gmane.comp.apache.mod-wackamole.general
Message-ID <[email protected]>
I just downloaded wackamole 2.1.1 (I've already installed spread 3.17.2
of course and got that working) and went about compiling it for Fedora Core 2.

Here's the problems I found:

* ife-sockpacket.c has a reference to ping_pkt (lines 87 and 88), but
  this isn't defined anywhere. My guess is that whoever added that code
  has a distro whose system includes define ping_pkt, but that is not
  the case with FC2. My solution was to simply put in a local ping_pkt
  variable (maybe it should be called something else in case that clashes
  with the original author's distro?) with a reasonable char array size
  (hey, I wasn't going to work it out exactly, see the actual compose_ping()
  function to see why :-) ):

    if (icmp) {
      unsigned char ping_pkt[255];
      compose_ping(ping_pkt, my_mac, remote_mac, new_ip, r_ip);
      sendto(_if_sock, ping_pkt, 42, 0,
             (struct sockaddr *)&iface, sizeof(iface));
    }

* wackatrl.c has two close(fd); statements that can be executed -
  one on successful return from the get_state() function (line 132)
  and another on exit from the main function (line 198). I would suggest
  that the first one is removed (from the get_state() function).

* wackatrl.c has faulty command line parsing of the -c option at the
  top of the main() function:

  char *filename = NULL;
  ...
  [Start getopt() loop]
  case 'c':
     filename=optarg;
     break;
  [Loop around getopt() until done]

  Now, if I run "wackatrl -c config_name -l", then the getopt() loop will
  finish with filename = NULL (should be filename = config_name). This is
  because optarg is overwritten each time around the getopt() loop, so the
  -l option has optarg = NULL and hence so will filename when it exits.
  The solution is to have a char buffer for filename and snprintf() optarg
  into it:

  char filename[BUFSIZ];
  ...
  [Start getopt() loop]
  case 'c':
     (void)strncpy(filename,optarg,BUFSIZ);
     break;
  [Loop around getopt() until done]

I hope these fixes are useful...

Richard K. Lloyd,           E-mail: [email protected]
Connect Internet Solutions,    WWW: http://www.connectinternetsolutions.com/
3, Brownlow Street,
Liverpool,
Merseyside, UK. L69 3GL