From 46e88e35952e9a155cde9bd7f87128f82855c04a Mon Sep 17 00:00:00 2001 From: Naram Qashat Date: Wed, 4 Aug 2010 22:05:45 -0400 Subject: 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. --- modules/core/enc_sha1.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'modules') 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(src.c_str()), src.length()); SHA1Final(reinterpret_cast(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; } -- cgit