fix empty arpcache bug

Matthias Weidle <[email protected]> Thu, 02 Oct 2003 17:41:47 +0200
Newsgroups gmane.comp.apache.mod-wackamole.general
Message-ID <916190000.1065109307@[10.182.4.195]>
hi all,

i've found a little problem in the arpcache code segment: if you happen to 
have an empty local arpcache and you try to start wackamole you won't 
succeed, because the sample_arp_cache() function is returning an NULL 
pointer in that very case.

please find attached a patch which is fixing the problem mentioned above. 
the patch is against wackamole-2.0.0.

btw: thanks for that great piece of software!

cheers,
-- matt.
fix-empty-arpcache.patch.txt (text/plain, 545 B)
--- arpcache.c	2002-09-22 20:43:34.000000000 +0200
+++ arpcache.c.new	2003-10-02 13:38:01.000000000 +0200
@@ -90,9 +90,12 @@
     }
   }
 	
-  if( count == 0 && arpcache_psize > 0 ){
-    arpcache_psize = 0;
+  if( count == 0 ){
+    Alarm(DEBUG, "Local arp-cache seems to be empty");
     if(arpcache_private) free(arpcache_private);
+    arpcache_psize = 0;
+    arpcache_private = malloc(sizeof(address));
+    arpcache_private[0] = 0;
   } else {
     /* adjust array size (FIXME: should we really do this?) */
     if( count != tmp_size ){