]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Added checking for bad base64 decodes
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 27 Dec 2005 21:17:00 +0000 (21:17 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 27 Dec 2005 21:17:00 +0000 (21:17 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2678 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_spanningtree.cpp

index 08058e68415895babf53c1c9f1a596efec024f41..4cfff58a0422b426321f3b1ff322b55b7091fbb8 100644 (file)
@@ -1247,11 +1247,14 @@ class TreeSocket : public InspSocket
                                        if ((ret.substr(0,7) != "ERROR :") && (ret.substr(0,6) != "CAPAB "))
                                        {
                                                int nbytes = from64tobits(out, ret.c_str(), 1024);
-                                               log(DEBUG,"m_spanningtree: decrypt %d bytes",nbytes);
-                                               ctx->Decrypt(out, result, nbytes, 0);
-                                               for (int t = 0; t < nbytes; t++)
-                                                       if (result[t] == '\7') result[t] = 0;
-                                               ret = result;
+                                               if (nbytes > 0)
+                                               {
+                                                       log(DEBUG,"m_spanningtree: decrypt %d bytes",nbytes);
+                                                       ctx->Decrypt(out, result, nbytes, 0);
+                                                       for (int t = 0; t < nbytes; t++)
+                                                               if (result[t] == '\7') result[t] = 0;
+                                                       ret = result;
+                                               }
                                        }
                                }
                                if (!this->ProcessLine(ret))
@@ -1283,9 +1286,7 @@ class TreeSocket : public InspSocket
                        log(DEBUG,"Plaintext line with padding = %d chars",ll);
                        ctx->Encrypt(line.c_str(), result, ll, 0);
                        log(DEBUG,"Encrypted.");
-                       to64frombits((unsigned char*)result64,
-                                       (unsigned char*)result,
-                                       ll);
+                       to64frombits((unsigned char*)result64,(unsigned char*)result,ll);
                        line = result64;
                        log(DEBUG,"Encrypted: %s",line.c_str());
                        //int from64tobits(char *out, const char *in, int maxlen);