From: Paul Date: Sun, 8 Feb 2009 00:36:54 +0000 (+0000) Subject: sanity check input to scan, ref/deref nodes during scanning X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/commitdiff_plain/e6f3dfb44301d4565dbff2eb89637c5d993ea24d sanity check input to scan, ref/deref nodes during scanning --HG-- branch : paul --- diff --git a/proxyscan/proxyscan.c b/proxyscan/proxyscan.c index 03b74e06..341eecf6 100644 --- a/proxyscan/proxyscan.c +++ b/proxyscan/proxyscan.c @@ -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 "); } 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? */ diff --git a/proxyscan/proxyscanqueue.c b/proxyscan/proxyscanqueue.c index 91febc84..fae99c5e 100644 --- a/proxyscan/proxyscanqueue.c +++ b/proxyscan/proxyscanqueue.c @@ -6,6 +6,7 @@ #include "proxyscan.h" #include "../irc/irc.h" #include "../core/error.h" +#include 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 */