mirror of
https://github.com/anope/anope.git
synced 2026-06-29 17:56:37 +02:00
fix for bug #1087. thanks to Obi_Wan for reporting and testing.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2350 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
+7
-4
@@ -370,7 +370,7 @@ class EMD5 : public Module
|
||||
}
|
||||
}
|
||||
|
||||
return EVENT_STOP;
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
|
||||
|
||||
@@ -383,8 +383,11 @@ class EMD5 : public Module
|
||||
EventReturn OnEncryptCheckLen(int passlen, int bufsize)
|
||||
{
|
||||
if (bufsize < 16)
|
||||
{
|
||||
fatal("enc_md5: md5_check_len(): buffer too small (%d)", bufsize);
|
||||
return EVENT_STOP;
|
||||
return EVENT_STOP;
|
||||
}
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
|
||||
|
||||
@@ -402,9 +405,9 @@ class EMD5 : public Module
|
||||
return EVENT_STOP;
|
||||
if (memcmp(buf, password, 16) == 0)
|
||||
{
|
||||
return EVENT_ALLOW;
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
return EVENT_CONTINUE;
|
||||
return EVENT_STOP;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+8
-7
@@ -32,22 +32,23 @@ class ENone : public Module
|
||||
memset(dest,0,size);
|
||||
strncpy(dest,src,len);
|
||||
dest[len] = '\0';
|
||||
return EVENT_STOP;
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
return EVENT_STOP;
|
||||
return EVENT_STOP;
|
||||
}
|
||||
|
||||
EventReturn OnEncryptInPlace(char *buf, int size)
|
||||
{
|
||||
return EVENT_STOP;
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
|
||||
EventReturn OnEncryptCheckLen(int passlen, int bufsize)
|
||||
{
|
||||
if(bufsize>=passlen) {
|
||||
return EVENT_STOP;
|
||||
if(bufsize>=passlen)
|
||||
{
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
return EVENT_ALLOW; // return 1
|
||||
return EVENT_STOP;
|
||||
}
|
||||
|
||||
EventReturn OnDecrypt(const char *src, char *dest, int size) {
|
||||
@@ -62,7 +63,7 @@ class ENone : public Module
|
||||
{
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
return EVENT_CONTINUE;
|
||||
return EVENT_STOP;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
+8
-5
@@ -367,14 +367,14 @@ class EOld : public Module
|
||||
for (i = 0; i < 32; i += 2)
|
||||
dest[i / 2] = XTOI(digest[i]) << 4 | XTOI(digest[i + 1]);
|
||||
|
||||
if(debug)
|
||||
if(debug)
|
||||
{
|
||||
memset(tmp,0,33);
|
||||
binary_to_hex((unsigned char *)dest,tmp,16);
|
||||
alog("enc_old: Converted [%s] to [%s]",src,tmp);
|
||||
}
|
||||
|
||||
return EVENT_STOP;
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
|
||||
|
||||
@@ -387,8 +387,11 @@ class EOld : public Module
|
||||
EventReturn OnEncryptCheckLen(int passlen, int bufsize)
|
||||
{
|
||||
if (bufsize < 16)
|
||||
{
|
||||
fatal("enc_old: old_check_len(): buffer too small (%d)", bufsize);
|
||||
return EVENT_STOP;
|
||||
return EVENT_STOP;
|
||||
}
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
|
||||
|
||||
@@ -405,12 +408,12 @@ class EOld : public Module
|
||||
{
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
return EVENT_CONTINUE;
|
||||
return EVENT_STOP;
|
||||
}
|
||||
|
||||
EventReturn OnDecrypt(const char *src, char *dest, int size)
|
||||
{
|
||||
return EVENT_CONTINUE; // 0
|
||||
return EVENT_STOP; // 0
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
+12
-10
@@ -204,7 +204,7 @@ class ESHA1 : public Module
|
||||
unsigned char tmp[41];
|
||||
|
||||
if (size < 20)
|
||||
return EVENT_ALLOW;
|
||||
return EVENT_STOP;
|
||||
|
||||
memset(dest,0,size);
|
||||
|
||||
@@ -224,7 +224,7 @@ class ESHA1 : public Module
|
||||
alog("enc_sha1: hashed password to [%s]",tmp);
|
||||
}
|
||||
}
|
||||
return EVENT_STOP;
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
|
||||
|
||||
@@ -233,11 +233,10 @@ class ESHA1 : public Module
|
||||
char tmp[41];
|
||||
|
||||
memset(tmp,0,41);
|
||||
if(OnEncrypt(buf, strlen(buf), tmp, size)==EVENT_STOP)
|
||||
if(OnEncrypt(buf, strlen(buf), tmp, size)==EVENT_ALLOW)
|
||||
{
|
||||
memcpy(buf, tmp, size);
|
||||
} else {
|
||||
return EVENT_STOP;
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
return EVENT_STOP;
|
||||
}
|
||||
@@ -246,8 +245,11 @@ class ESHA1 : public Module
|
||||
EventReturn OnEncryptCheckLen(int passlen, int bufsize)
|
||||
{
|
||||
if (bufsize < 20)
|
||||
{
|
||||
fatal("enc_sha1: sha1_check_len(): buffer too small (%d)", bufsize);
|
||||
return EVENT_STOP;
|
||||
return EVENT_STOP;
|
||||
}
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
|
||||
|
||||
@@ -260,13 +262,13 @@ class ESHA1 : public Module
|
||||
EventReturn OnCheckPassword(const char *plaintext, const char *password)
|
||||
{
|
||||
char buf[BUFSIZE];
|
||||
if (OnEncrypt(plaintext, strlen(plaintext), buf, sizeof(buf)) == EVENT_ALLOW)
|
||||
return EVENT_STOP;
|
||||
if (memcmp(buf, password, 20) == 0)
|
||||
if (OnEncrypt(plaintext, strlen(plaintext), buf, sizeof(buf)) == EVENT_STOP)
|
||||
return EVENT_STOP;
|
||||
if (memcmp(buf, password, 20) == 0)
|
||||
{
|
||||
return EVENT_ALLOW;
|
||||
}
|
||||
return EVENT_CONTINUE;
|
||||
return EVENT_STOP;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
+9
-19
@@ -26,10 +26,8 @@ int enc_encrypt(const char *src, int len, char *dest, int size)
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnEncrypt, OnEncrypt(src, len, dest, size));
|
||||
if (MOD_RESULT == EVENT_ALLOW)
|
||||
return 1;
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return -1;
|
||||
return 0;
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,10 +40,8 @@ int enc_encrypt_in_place(char *buf, int size)
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnEncryptInPlace, OnEncryptInPlace(buf, size));
|
||||
if (MOD_RESULT == EVENT_ALLOW)
|
||||
return 1;
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return -1;
|
||||
return 0;
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
@@ -62,15 +58,13 @@ int enc_encrypt_check_len(int passlen, int bufsize)
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnEncryptCheckLen, OnEncryptCheckLen(passlen, bufsize));
|
||||
if (MOD_RESULT == EVENT_ALLOW)
|
||||
return 1;
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return -1;
|
||||
return 0;
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt encrypted string `src' into buffer `dest' of length `len'.
|
||||
* Returns 1 (not 0) on success, 0 if the encryption algorithm does not
|
||||
* Returns 1 (not 0) on success, -1 if the encryption algorithm does not
|
||||
* allow decryption, and -1 if another failure occurred (e.g. destination
|
||||
* buffer too small).
|
||||
**/
|
||||
@@ -80,9 +74,7 @@ int enc_decrypt(const char *src, char *dest, int size)
|
||||
FOREACH_RESULT(I_OnDecrypt, OnDecrypt(src, dest, size));
|
||||
if (MOD_RESULT == EVENT_ALLOW)
|
||||
return 1;
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return -1;
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +82,7 @@ int enc_decrypt(const char *src, char *dest, int size)
|
||||
* `password'. Return value is:
|
||||
* 1 if the password matches
|
||||
* 0 if the password does not match
|
||||
* -1 if an error occurred while checking
|
||||
* 0 if an error occurred while checking
|
||||
**/
|
||||
int enc_check_password(const char *plaintext, const char *password)
|
||||
{
|
||||
@@ -98,8 +90,6 @@ int enc_check_password(const char *plaintext, const char *password)
|
||||
FOREACH_RESULT(I_OnCheckPassword, OnCheckPassword(plaintext, password));
|
||||
if (MOD_RESULT == EVENT_ALLOW)
|
||||
return 1;
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user