summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/elogin/md5calc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/elogin/md5calc.c b/src/elogin/md5calc.c
index d5dbed3..e2c9235 100644
--- a/src/elogin/md5calc.c
+++ b/src/elogin/md5calc.c
@@ -12,6 +12,8 @@
#include <stdio.h>
#include "mt_rand.h"
+#include "common/strlib.h"
+
#ifndef UINT_MAX
#define UINT_MAX 4294967295U
#endif
@@ -324,6 +326,10 @@ char *MD5_saltcrypt(const char *key, const char *salt)
// Hash the buffer back into sbuf
MD5_String(buf, sbuf);
+ // explicitly truncate the hash to fit in obuf
+ int salt_len = (int)safestrnlen(salt, 30);
+ sbuf[30 - salt_len] = '\0';
+
snprintf(obuf, 32, "!%s$%s", salt, sbuf);
return(obuf);
}