summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-27 21:17:00 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-27 21:17:00 +0000
commit5e1a481ce63eb217492937b84117a1bf5c44b4f2 (patch)
treef99cea97b7a483bd6be1b46f84459e3d3a629950
parent271bd38c32869b3fefadbb2749043451ac9e6f28 (diff)
Added checking for bad base64 decodes
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2678 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/m_spanningtree.cpp17
1 files changed, 9 insertions, 8 deletions
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);