summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2009-10-02 22:48:57 +0200
committerDavid Sommerseth <dazo@users.sourceforge.net>2009-10-02 22:48:57 +0200
commit892874947d70b75a932d5990a0e9c43685cfde79 (patch)
tree1cca3de60462031f46af5c055dba68c225c94c1d /common
parenta3a50982429998f7d7969486b45dadbf36754a9d (diff)
downloadeurephia-892874947d70b75a932d5990a0e9c43685cfde79.tar.gz
eurephia-892874947d70b75a932d5990a0e9c43685cfde79.tar.xz
eurephia-892874947d70b75a932d5990a0e9c43685cfde79.zip
Fixed some memory issues and a memory leak in passwd.c
Diffstat (limited to 'common')
-rw-r--r--common/passwd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/common/passwd.c b/common/passwd.c
index 9e7dacb..0f8425d 100644
--- a/common/passwd.c
+++ b/common/passwd.c
@@ -526,7 +526,9 @@ char *eurephia_pwd_crypt(eurephiaCTX *ctx, const char *key, const char *salt) {
// If we have a salt, use it
snprintf(saltstr, MAX_SALT_LEN+20, "%s%c", salt, 0);
}
- result = sha512_crypt_r(key, saltstr, maxrounds, buffer, buflen);
+ // For some reason, if not strdup()ing 'buffer' and returning buffer it causes a memory leak
+ result = strdup_nullsafe(sha512_crypt_r(key, saltstr, maxrounds, buffer, buflen));
+ free_nullsafe(NULL, buffer);
return result;
}
@@ -554,7 +556,8 @@ char *eurephia_quick_hash(const char *salt, const char *pwd) {
}
if( salt != NULL ) {
- tmp = (char *) malloc_nullsafe(NULL, strlen_nullsafe(salt) + len + 2);
+ tmp = (char *) malloc_nullsafe(NULL, strlen_nullsafe(salt) + len + 10);
+ memset(tmp,0, strlen_nullsafe(salt) + len + 2);
sprintf(tmp, "%s%s", pwd, salt);
} else {
tmp = strdup_nullsafe(pwd);