diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2009-10-02 22:48:57 +0200 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-10-02 22:48:57 +0200 |
commit | 892874947d70b75a932d5990a0e9c43685cfde79 (patch) | |
tree | 1cca3de60462031f46af5c055dba68c225c94c1d /common/passwd.c | |
parent | a3a50982429998f7d7969486b45dadbf36754a9d (diff) | |
download | eurephia-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/passwd.c')
-rw-r--r-- | common/passwd.c | 7 |
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); |