summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Shyti <andi@etezian.org>2012-09-03 23:13:05 +0200
committerAndi Shyti <andi@etezian.org>2012-09-03 23:13:05 +0200
commit983119577046905c6303222f2c871b0cfd49e2fa (patch)
tree35b756d6662c8ae6ea5bc1d1a3327ebde88c668c
parent44db5c7c6ca77d6a649f3e7f284164a18305c1aa (diff)
crypt_sha256: fixed lenght password allocation
Signed-off-by: Andi Shyti <andi@etezian.org>
-rw-r--r--src/crypt_sha256.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/crypt_sha256.c b/src/crypt_sha256.c
index fb19a07..5bbed5e 100644
--- a/src/crypt_sha256.c
+++ b/src/crypt_sha256.c
@@ -16,7 +16,7 @@
SHA256_DIGEST_LENGTH
#define LEN_ENC64 64
#define LEN_SHA_STR 8
-#define LEN_FINAL_PASSWD LEN_ENC64 + LEN_SHA_STR + 1
+#define LEN_FINAL_PASSWD LEN_ENC64 + LEN_SHA_STR
uint8_t check_passwd(const char *p, size_t len)
@@ -61,10 +61,10 @@ char* get_crypt_sha256(const char *p)
SHA256_DIGEST_LENGTH + len + LEN_RAND_STR);
- final_pwd = (char*) malloc (LEN_FINAL_PASSWD);
+ final_pwd = (char*) malloc (LEN_FINAL_PASSWD + 1);
memcpy(final_pwd, SHA_STR, LEN_SHA_STR);
memcpy(final_pwd+8, enc64_pwd, LEN_ENC64);
- final_pwd[LEN_SHA_STR + LEN_FINAL_PASSWD] = '\0';
+ final_pwd[LEN_FINAL_PASSWD] = '\0';
return final_pwd;
}