fix coredump in feature lookup code
authorThomas Helvey <tom.helvey@cox.net>
Sat, 11 Jan 2003 11:24:22 +0000 (11:24 +0000)
committerThomas Helvey <tom.helvey@cox.net>
Sat, 11 Jan 2003 11:24:22 +0000 (11:24 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@910 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/client.c
ircd/ircd_features.c

index 6a801dd8830fcc5fd32fe6b486b0799c8c1c4ee7..0876d1def0f1dd000326d27d4317ac17c4d4284f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-01-11  Thomas Helvey <tom.helvey@cox.net>
+       * ircd/client.c, ircd/ircd_feature.c: Bugfix, the feature
+       table data was in a different order than the feature data
+       structure, which resulted in a wild index being used in
+       feature_bool. The feature_bool function didn't check it's
+       index before indexing the features array resulting in
+       a core dump on /oper.
 2003-01-10  Thomas Helvey <tom.helvey@cox.net>
        * include/client.h, include/res.h, include/s_bsd.h,
        ircd/ircd.c, ircd/list.c ircd/m_connect.c, ircd/res_adns.c,
index f960a1d99f470e29e5e817e71b494c1d035a218a..670da3a291609f03494974f734aaba72ae69a535 100644 (file)
@@ -104,6 +104,7 @@ void client_add_sendq(struct Connection* con, struct Connection** con_p)
 static struct
 {
   enum Priv priv;
+  enum Feature feat;
   enum
     {
       FEATFLAG_DISABLES_PRIV,
@@ -112,7 +113,6 @@ static struct
       FEATFLAG_LOCAL_OPERS,
       FEATFLAG_ALL_OPERS
     } flag;
-  enum Feature feat;
 } feattab[] =
   {
     { PRIV_WHOX, FEAT_LAST_F, FEATFLAG_ALL_OPERS },
@@ -201,7 +201,7 @@ client_set_privs(struct Client *client, struct ConfItem *oper)
   {
     if (PrivHas(&oper->privs_dirty, feattab[i].priv))
       continue;
-    if (feattab[i].feat != FEAT_LAST_F && !feature_bool(feattab[i].priv))
+    if (feattab[i].feat != FEAT_LAST_F && !feature_bool(feattab[i].feat))
       continue;
     switch (feattab[i].flag)
     {
index ccbd9fe2a61f22fe06f4aa1d5cecc6ac7632fb2a..47b6818f1c7e388d4a6786f6032504c0cab78d83 100644 (file)
@@ -801,6 +801,9 @@ feature_int(enum Feature feat)
 int
 feature_bool(enum Feature feat)
 {
+  assert(feat <= FEAT_LAST_F);
+  if (FEAT_LAST_F < feat)
+    return 0;
   assert(features[feat].feat == feat);
   assert((features[feat].flags & FEAT_MASK) == FEAT_BOOL);