Fix handling of invalid IPs in Client blocks; pretty up /stats i.
authorMichael Poole <mdpoole@troilus.org>
Sat, 19 Feb 2005 21:55:37 +0000 (21:55 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sat, 19 Feb 2005 21:55:37 +0000 (21:55 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1319 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/ircd_parser.y
ircd/s_stats.c

index a7e32ba5e1c230719d398c03fc50928d592c7e82..574c131b341022c38b3014bef0f2d7bf16269fbf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,9 @@
 
 2005-02-19  Michael Poole <mdpoole@troilus.org>
 
+       * ircd/ircd_parser.y (clientblock): Parse IP address before
+       allocating ConfItem; if the parse fails, generate an error.
+
        * ircd/s_err.c (RPL_STATSCLINE): Add format field to prefix IPv6
        addresses starting with ':'.
        (RPL_STATSILINE): Likewise.
@@ -18,6 +21,8 @@
 
        * ircd/s_stats.c (stats_configured_links): Pass the appropriate
        argument for the RPL_STATSxLINE changes.
+       Change RPL_STATSILINE to use * instead of <NULL> when IP or host
+       is null.
 
 2005-02-18  Michael Poole <mdpoole@troilus.org>
 
index 0fb55730763d3b2e216b5540fd9461c2f3d8c2b1..cf272474851634b6f14ad0d3d8e905f37612ba79 100644 (file)
@@ -650,20 +650,24 @@ clientblock: CLIENT
 }
 '{' clientitems '}' ';'
 {
-  struct ConfItem *aconf = make_conf(CONF_CLIENT);
+  struct irc_in_addr addr;
   unsigned char addrbits;
-  aconf->username = username;
-  aconf->host = host;
-  if (ip && ipmask_parse(ip, &aconf->address.addr, &addrbits)) {
+
+  if (ip && !ipmask_parse(ip, &addr, &addrbits)) {
+    parse_error("Invalid IP address in block");
+    MyFree(username);
+    MyFree(host);
+    MyFree(ip);
+  } else {
+    struct ConfItem *aconf = make_conf(CONF_CLIENT);
+    aconf->username = username;
+    aconf->host = host;
+    memcpy(&aconf->address.addr, &addr, sizeof(aconf->address.addr));
     aconf->addrbits = addrbits;
     aconf->name = ip;
-  } else {
-    MyFree(ip);
-    aconf->addrbits = -1;
-    DupString(aconf->name, "*");
+    aconf->conn_class = c_class ? c_class : find_class("default");
+    aconf->maximum = maxlinks;
   }
-  aconf->conn_class = c_class ? c_class : find_class("default");
-  aconf->maximum = maxlinks;
   host = NULL;
   username = NULL;
   c_class = NULL;
index 9c843a4c7e6acf7d61a7b4edb49fbf53f0976981..d61f0f59327840f5172eca6e045417608fc7bb66 100644 (file)
@@ -100,12 +100,16 @@ stats_configured_links(struct Client *sptr, const struct StatDesc* sd,
       hub_limit = BadPtr(tmp->hub_limit) ? null : tmp->hub_limit;
       maximum = tmp->maximum;
       port = tmp->address.port;
+
       if (tmp->status & CONF_UWORLD)
        send_reply(sptr, RPL_STATSULINE, host);
       else if (tmp->status & CONF_SERVER)
        send_reply(sptr, RPL_STATSCLINE, name, (host[0] == ':' ? "0" : ""), host, port, maximum, hub_limit, get_conf_class(tmp));
       else if (tmp->status & CONF_CLIENT)
-        send_reply(sptr, RPL_STATSILINE, host, maximum, (name[0] == ':' ? "0" : ""), name, port, get_conf_class(tmp));
+        send_reply(sptr, RPL_STATSILINE,
+                   (tmp->host ? tmp->host : "*"), maximum,
+                   (name[0] == ':' ? "0" : ""), (tmp->name ? tmp->name : "*"),
+                   port, get_conf_class(tmp));
       else if (tmp->status & CONF_OPERATOR)
        send_reply(sptr, RPL_STATSOLINE, username, host, name, get_conf_class(tmp));
     }