summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaram Qashat <cyberbotx@cyberbotx.com>2010-08-04 22:05:45 -0400
committerNaram Qashat <cyberbotx@cyberbotx.com>2010-08-04 22:05:45 -0400
commit46e88e35952e9a155cde9bd7f87128f82855c04a (patch)
treeeee6f33e9cd62e7cbb80f2fe3968182c9b2772ad
parentf78243b6b1157cc030817df8fba605ece16f2f6b (diff)
Remove need to have a dynmaically allocated C-string in enc_sha1, it was being made too big (by the default config PassLen of 32) anyways.
-rw-r--r--modules/core/enc_sha1.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/modules/core/enc_sha1.cpp b/modules/core/enc_sha1.cpp
index a5235c594..4047f539a 100644
--- a/modules/core/enc_sha1.cpp
+++ b/modules/core/enc_sha1.cpp
@@ -138,7 +138,7 @@ void SHA1Update(SHA1_CTX *context, const unsigned char *data, uint32 len)
/* Add padding and return the message digest. */
-void SHA1Final(unsigned char digest[20], SHA1_CTX *context)
+void SHA1Final(unsigned char digest[21], SHA1_CTX *context)
{
uint32 i;
unsigned char finalcount[8];
@@ -182,12 +182,10 @@ class ESHA1 : public Module
EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest)
{
SHA1_CTX context;
- char *digest = new char[Config.PassLen];
+ char digest[21] = "";
Anope::string buf = "sha1:";
Anope::string cpass;
- memset(digest, 0, 32);
-
SHA1Init(&context);
SHA1Update(&context, reinterpret_cast<const unsigned char *>(src.c_str()), src.length());
SHA1Final(reinterpret_cast<unsigned char *>(digest), &context);
@@ -196,7 +194,6 @@ class ESHA1 : public Module
buf += cpass;
Alog(LOG_DEBUG_2) << "(enc_sha1) hashed password from [" << src << "] to [" << buf << "]";
dest = buf;
- delete [] digest;
return EVENT_ALLOW;
}