]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Fix some issues paul found.
authorGunnar Beutner <redacted>
Wed, 26 Jun 2013 21:48:50 +0000 (23:48 +0200)
committerGunnar Beutner <redacted>
Wed, 26 Jun 2013 21:48:50 +0000 (23:48 +0200)
--HG--
branch : shroudtrusts

trusts/trusts.h
trusts/trusts_management.c

index 48e21d1e9117999a4ee81797e8a252b8fa70d8ab..7691dfdf328a2ff205b3864210bcf440c52d9db1 100644 (file)
@@ -43,7 +43,7 @@
 #define TRUST_NO_CLEANUP 2
 #define TRUST_PROTECTED 4
 
-#define TRUST_MIN_UNPRIVILEGED_BITS_IPV4 (96 + 32)
+#define TRUST_MIN_UNPRIVILEGED_BITS_IPV4 (96 + 20)
 #define TRUST_MIN_UNPRIVILEGED_BITS_IPV6 32
 
 #define TRUST_MIN_UNPRIVILEGED_NODEBITS_IPV4 (96 + 24)
index 013cd35147307d190db60903e3feaa8a12b27319..4ad5ca10050a5e7e7a3049ed72a4f40a7e2df6f3 100644 (file)
@@ -383,8 +383,10 @@ static int modifyexpires(void *arg, char *expires, nick *source, int override) {
   trustgroup *tg = arg;
   int howlong = durationtolong(expires);
 
-  if((howlong < 0) || (howlong > MAXDURATION))
+  if((howlong < 0) || (howlong > MAXDURATION)) {
+    controlreply(source, "Duration cannot be negative or greater than %s (use 0 instead if you don't want the group to expire).", longtoduration(MAXDURATION, 0));
     return 0;
+  }
 
   if(howlong)
     tg->expires = getnettime() + howlong;
@@ -460,6 +462,9 @@ static int modifynodebits(void *arg, char *num, nick *source, int override) {
     return 0;
   }
 
+  if(irc_in_addr_is_ipv4(&th->ip))
+    nodebits += 96;
+
   if(!override) {
     int minbits = irc_in_addr_is_ipv4(&th->ip)?TRUST_MIN_UNPRIVILEGED_NODEBITS_IPV4:TRUST_MIN_UNPRIVILEGED_NODEBITS_IPV6;
 
@@ -469,11 +474,8 @@ static int modifynodebits(void *arg, char *num, nick *source, int override) {
     }
   }
 
-  if(irc_in_addr_is_ipv4(&th->ip))
-    nodebits += 96;
-
   if(nodebits<th->bits) {
-    controlreply(source, "Node bits must be smaller than the trusted CIDR's subnet size.");
+    controlreply(source, "Node bits must be smaller or equal to the trusted CIDR's subnet size.");
     return 0;
   }
 
@@ -621,7 +623,7 @@ static int trusts_cmdtrusthostmodify(void *source, int cargc, char **cargv) {
   controlreply(sender, "Host modified.");
 
   controlwall(NO_OPER, NL_TRUSTS, "%s TRUSTMODIFIED'ed host '%s' in group '%s' (field: %s, value: %s)", controlid(sender), trusts_cidr2str(&ip, bits), tg->name->content, what, to);
-  trustlog(tg, sender->authname, "Modified %s for host '%s': %s", what, tg->name->content, to);
+  trustlog(tg, sender->authname, "Modified %s for host '%s': %s", what, trusts_cidr2str(&ip, bits), to);
 
   return CMD_OK;
 }
@@ -685,6 +687,11 @@ static int trusts_cmdtrustcomment(void *source, int cargc, char **cargv) {
   name = cargv[0];
   comment = cargv[1];
 
+  if(strlen(comment)>TRUSTLOGLEN) {
+    controlreply(sender, "Your comment is too long (max: %d characters).", TRUSTLOGLEN);
+    return CMD_OK;
+  }
+
   tg = tg_strtotg(name);
 
   if(!tg) {
@@ -692,7 +699,7 @@ static int trusts_cmdtrustcomment(void *source, int cargc, char **cargv) {
     return CMD_OK;
   }
 
-    controlwall(NO_OPER, NL_TRUSTS, "%s TRUSTCOMMENT'ed group '%s': %s", controlid(sender), tg->name->content, comment);
+  controlwall(NO_OPER, NL_TRUSTS, "%s TRUSTCOMMENT'ed group '%s': %s", controlid(sender), tg->name->content, comment);
   trustlog(tg, sender->authname, "Comment: %s", comment);
 
   return CMD_OK;