--- main.c.orig	2011-02-12 02:14:29.000000000 +0100
+++ main.c	2011-02-12 02:11:44.000000000 +0100
@@ -31,7 +31,8 @@
 int main(int argc,char **argv)
 {
    char *dev, *app;
-   char *filter, *buffer, ldname[50];
+   dev = NULL;
+   char *filter, *buffer, *ldname;
    char errbuf[PCAP_ERRBUF_SIZE];
    extern char *optarg;
    int option, option_index;
@@ -105,14 +106,6 @@
         fprintf(stderr, "You must be root, Sorry\n\n");
         return -1;
      }
-
-   /* finding a suitable device */
-   dev = pcap_lookupdev(errbuf);
-   if (dev==NULL)
-     {
-	fprintf (stderr, "Error: can't find a suitable interface to use: %s\n", errbuf);
-	return -1;
-     }
    
    /*
    res = pcap_findalldevs(&devices, errbuf);
@@ -142,12 +135,6 @@
    pcap_freealldevs(devices);
    */
    
-   if  ((L = libnet_init (LIBNET_LINK, dev, errbuf))==NULL)
-     {
-	fprintf(stderr, "Error: can't initialize libnet engine: %s", errbuf);
-	fprintf(stderr, "Have you activate a non-loopback iface? (man ifconfig)\n");
-	exit(-1);
-     }
 
    line_s = row_s = cont = lg = 0;
    option_index = 0;
@@ -156,7 +143,7 @@
    memset (&flags, 0, sizeof (struct FLAGSTRUCT));
    flags.promisc = 1;  /*default is promisc */
    logname = filter = buffer = tcpdl = NULL;
-   strcpy(ldname,"NULL");
+   ldname = NULL;
 
    /* get global time */
    tm = time(NULL);
@@ -171,7 +158,7 @@
 	  break;
         case 'i':
 	  (app=optarg);
-	  strcpy(dev,app);
+	  dev = app;
 	  break;
 	case 'l': /* log to file */
 	  flags.l=1;
@@ -273,7 +260,7 @@
 	/* only long options */
 	case '\0':
 	  if (!strcmp(long_options[option_index].name,"ld"))
-	    strcpy(ldname,optarg);
+	    ldname = optarg;
 	  break;
 	default:
 	  usage(argv[0]);
@@ -281,6 +268,22 @@
        }
    /* END OF ARGS SWITCH */
 
+   /* finding a suitable device */
+   if(dev == NULL) dev = pcap_lookupdev(errbuf);
+   if (dev==NULL)
+     {
+	fprintf (stderr, "Error: can't find a suitable interface to use: %s\n", errbuf);
+	return -1;
+     }
+
+   if  ((L = libnet_init (LIBNET_LINK, dev, errbuf))==NULL)
+     {
+	fprintf(stderr, "Error: can't initialize libnet engine: %s", errbuf);
+	fprintf(stderr, "Have you activate a non-loopback iface? (man ifconfig)\n");
+        fprintf(stderr, "Maybe autodetection is failing, try with \"-i interface\"\n");
+	exit(-1);
+     }
+
    if (dev==NULL)
      {
 	fprintf(stderr, "Cannot find a suitable network interface!\n");
