Răsfoiți Sursa

* Port [3500] to 1.2.14
* Fix checking wrong cookie hashes



svn: 3501

Bryan Drewery 19 ani în urmă
părinte
comite
ebcf24ea65
2 a modificat fișierele cu 9 adăugiri și 7 ștergeri
  1. 8 6
      src/mod/irc.mod/irc.c
  2. 1 1
      src/mod/irc.mod/mode.c

+ 8 - 6
src/mod/irc.mod/irc.c

@@ -417,18 +417,20 @@ sdprintf("hash: %s", hash);
 #endif
 #endif
 
 
   /* Compare the expected hash to each of the given hashes */
   /* Compare the expected hash to each of the given hashes */
-
-
   /* indexHint, Which position of the +ooo are we? (1) could be either index (1) or (2).. but not (0). */
   /* indexHint, Which position of the +ooo are we? (1) could be either index (1) or (2).. but not (0). */
+
+  /* See if any of the cookies match the hash we want */
   for (size_t i = indexHint; i < hashes; ++i) {
   for (size_t i = indexHint; i < hashes; ++i) {
-    cookie += ((i << 1) + i); /* i * 3 */
-    if ((hash[HASH_INDEX1(i)] == cookie[0] && 
-         hash[HASH_INDEX2(i)] == cookie[1] && 
-         hash[HASH_INDEX3(i)] == cookie[2])) {
+    const char *cookie_index = cookie + ((i << 1) + i); /* i * 3 */
+
+    if ((hash[HASH_INDEX1(i)] == cookie_index[0] && 
+         hash[HASH_INDEX2(i)] == cookie_index[1] && 
+         hash[HASH_INDEX3(i)] == cookie_index[2])) {
       return 0;
       return 0;
     }
     }
   }
   }
 
 
+  /* None matched -> failure */
   return BC_HASH;
   return BC_HASH;
 }
 }
 
 

+ 1 - 1
src/mod/irc.mod/mode.c

@@ -1125,7 +1125,7 @@ gotmode(char *from, char *msg)
                    * Punish the opper lastly (and once)
                    * Punish the opper lastly (and once)
                  */
                  */
                 bool failure = 0;
                 bool failure = 0;
-                for (i = 0; i < modecnt; i++) {
+                for (i = 0; i < (modecnt - 1); i++) { /* Don't need to hit the -b */
                   if (msign == '+' && mmode == 'o') {
                   if (msign == '+' && mmode == 'o') {
                     mv = ismember(chan, mparam);
                     mv = ismember(chan, mparam);