summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2020-07-14 23:49:16 +0000
committergumi <git@gumi.ca>2020-07-14 23:49:16 +0000
commitc25ee06f212172fa77ba8ae14c6de0b2e1c1210c (patch)
tree5e05d32714249ef057c83c080359ba361b624b2f
parentf8587deeb756f561852494987fbe31d71b5dbc09 (diff)
downloadevol-hercules-c25ee06f212172fa77ba8ae14c6de0b2e1c1210c.tar.gz
evol-hercules-c25ee06f212172fa77ba8ae14c6de0b2e1c1210c.tar.bz2
evol-hercules-c25ee06f212172fa77ba8ae14c6de0b2e1c1210c.tar.xz
evol-hercules-c25ee06f212172fa77ba8ae14c6de0b2e1c1210c.zip
fix a gcc truncation warning in md5calc
-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);
}