Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2005-02-19 21:55:47 UTC
Modified files:
ChangeLog ircd/ircd_parser.y ircd/s_stats.c
Log message:
Fix handling of invalid IPs in Client blocks; pretty up /stats i.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.555 ircu2.10/ChangeLog:1.556
--- ircu2.10/ChangeLog:1.555 Sat Feb 19 13:50:47 2005
+++ ircu2.10/ChangeLog Sat Feb 19 13:55:37 2005
@@ -11,6 +11,9 @@
2005-02-19 Michael Poole <[EMAIL PROTECTED]>
+ * 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 <[EMAIL PROTECTED]>
Index: ircu2.10/ircd/ircd_parser.y
diff -u ircu2.10/ircd/ircd_parser.y:1.37 ircu2.10/ircd/ircd_parser.y:1.38
--- ircu2.10/ircd/ircd_parser.y:1.37 Fri Feb 18 20:45:53 2005
+++ ircu2.10/ircd/ircd_parser.y Sat Feb 19 13:55:37 2005
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
- * $Id: ircd_parser.y,v 1.37 2005/02/19 04:45:53 entrope Exp $
+ * $Id: ircd_parser.y,v 1.38 2005/02/19 21:55:37 entrope Exp $
*/
%{
@@ -650,20 +650,24 @@
}
'{' 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: ircu2.10/ircd/s_stats.c
diff -u ircu2.10/ircd/s_stats.c:1.32 ircu2.10/ircd/s_stats.c:1.33
--- ircu2.10/ircd/s_stats.c:1.32 Sat Feb 19 09:15:37 2005
+++ ircu2.10/ircd/s_stats.c Sat Feb 19 13:55:37 2005
@@ -60,7 +60,7 @@
/** @file
* @brief Report configuration lines and other statistics from this
* server.
- * @version $Id: s_stats.c,v 1.32 2005/02/19 17:15:37 entrope Exp $
+ * @version $Id: s_stats.c,v 1.33 2005/02/19 21:55:37 entrope Exp $
*
* Note: The info is reported in the order the server uses
* it--not reversed as in ircd.conf!
@@ -100,12 +100,16 @@
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));
}
----------------------- End of diff -----------------------