From 5e1a481ce63eb217492937b84117a1bf5c44b4f2 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 27 Dec 2005 21:17:00 +0000 Subject: Added checking for bad base64 decodes git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2678 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/modules/m_spanningtree.cpp') diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 08058e684..4cfff58a0 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -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); -- cgit v1.2.3