]> jfr.im git - irc/quakenet/newserv.git/commitdiff
sanity check input to scan, ref/deref nodes during scanning
authorPaul <redacted>
Sun, 8 Feb 2009 00:36:54 +0000 (00:36 +0000)
committerPaul <redacted>
Sun, 8 Feb 2009 00:36:54 +0000 (00:36 +0000)
--HG--
branch : paul

proxyscan/proxyscan.c
proxyscan/proxyscanqueue.c

index 03b74e06bed8bbfdef521c8f5907a8c19a47df9f..341eecf6da926e4957d3816147f8dd7a4d6386d2 100644 (file)
@@ -560,6 +560,8 @@ void killsock(scan *sp, int outcome) {
     }
   }
 
+  /* deref prefix (referenced in queuescan) */
+  derefnode(iptree,sp->node);
   freescan(sp);
 
   /* kick the queue.. */
@@ -923,6 +925,10 @@ int proxyscandoscan(void *sender, int cargc, char **cargv) {
   if (0 == ipmask_parse(cargv[0],&sin, &bits)) {
     sendnoticetouser(proxyscannick,np,"Usage: scan <ip>");
   } else {
+    if (bits != 128 || !irc_in_addr_is_ipv4(&sin) || irc_in_addr_is_loopback(&sin)) {
+      sendnoticetouser(proxyscannick,np,"You may only scan single IPv4 IP's");
+      return CMD_OK;
+    }
     sendnoticetouser(proxyscannick,np,"Forcing scan of %s",IPtostr(sin));
     // * Just queue the scans directly here.. plonk them on the priority queue * /
     node = refnode(iptree, &sin, bits); /* node leaks node here - should only allow to scan a nick? */
index 91febc841bcc697f3153df849ee2ee82c899f977..fae99c5e1cdf7dfd9d3450a66e0a6e64e334424e 100644 (file)
@@ -6,6 +6,7 @@
 #include "proxyscan.h"
 #include "../irc/irc.h"
 #include "../core/error.h"
+#include <assert.h>
 
 pendingscan *ps_normalqueue=NULL;
 pendingscan *ps_prioqueue=NULL;
@@ -25,6 +26,11 @@ void queuescan(patricia_node_t *node, short scantype, unsigned short port, char
    * b) newnick handler - which ignores clean hosts, only scans new hosts or dirty hosts
    * c) adding a new scan type (rare) 
    */
+
+  /* we should never have an internal node */
+  assert(node->prefix);
+  /* reference the node - we either start a or queue a single scan */
+  patricia_ref_prefix(node->prefix);
   
   /* If there are scans spare, just start it immediately.. 
    * provided we're not supposed to wait */