From d131c40c9ba8b2c50264c4e2e7207a42b96d1bfe Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Sat, 19 Feb 2005 21:55:37 +0000 Subject: [PATCH] Fix handling of invalid IPs in Client blocks; pretty up /stats i. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1319 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 5 +++++ ircd/ircd_parser.y | 24 ++++++++++++++---------- ircd/s_stats.c | 6 +++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7e32ba..574c131 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,9 @@ 2005-02-19 Michael Poole + * 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 when IP or host + is null. 2005-02-18 Michael Poole diff --git a/ircd/ircd_parser.y b/ircd/ircd_parser.y index 0fb5573..cf27247 100644 --- a/ircd/ircd_parser.y +++ b/ircd/ircd_parser.y @@ -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; diff --git a/ircd/s_stats.c b/ircd/s_stats.c index 9c843a4..d61f0f5 100644 --- a/ircd/s_stats.c +++ b/ircd/s_stats.c @@ -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)); } -- 2.20.1