gamelinux / passivedns

A network sniffer that logs all DNS server replies for use in a passive DNS setup
http://gamelinux.org/
1.67k stars 372 forks source link

cosmetic: exit cleanly when unable to read pcap rather than segfault #20

Closed jpvlsmv closed 11 years ago

jpvlsmv commented 12 years ago

Rather than litter the filesystem with core files, here's a simple patch that will exit cleanly when the capture device/file can not be read:

--- passivedns.c.orig   2012-05-02 17:29:22.000000000 +0000
+++ passivedns.c        2012-05-02 17:30:12.000000000 +0000
@@ -1142,6 +1142,11 @@

     }

+    if (config.handle == NULL) {
+       game_over();
+       return (1);
+    }
+
     /** segfaults on empty pcap! */
     if ((pcap_compile(config.handle, &config.cfilter, config.bpff, 1, config.net_mask)) == -1) {
             olog("[*] Error pcap_compile user_filter: %s\n", pcap_geterr(config.handle));
gamelinux commented 12 years ago

On 05/02/2012 07:33 PM, Joe Moore wrote:

  • if (config.handle == NULL) {
  • game_over();
  • return (1);
  • }

Thanks, Added and pushed :)

E