summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/php_crypt_r.c1
-rw-r--r--ext/standard/tests/strings/bug50052.phpt12
2 files changed, 13 insertions, 0 deletions
diff --git a/ext/standard/php_crypt_r.c b/ext/standard/php_crypt_r.c
index e0465fdb59..4307f4c903 100644
--- a/ext/standard/php_crypt_r.c
+++ b/ext/standard/php_crypt_r.c
@@ -208,6 +208,7 @@ char * php_md5_crypt_r(const char *pw, const char *salt, char *out) {
if (strncpy_s(passwd + MD5_MAGIC_LEN, MD5_HASH_MAX_LEN - MD5_MAGIC_LEN, sp, sl + 1) != 0) {
goto _destroyCtx1;
}
+ passwd[MD5_MAGIC_LEN + sl] = '\0';
strcat_s(passwd, MD5_HASH_MAX_LEN, "$");
#else
/* VC6 version doesn't have strcat_s or strncpy_s */
diff --git a/ext/standard/tests/strings/bug50052.phpt b/ext/standard/tests/strings/bug50052.phpt
new file mode 100644
index 0000000000..96d859992e
--- /dev/null
+++ b/ext/standard/tests/strings/bug50052.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #50052 (Different Hashes on Windows and Linux on wrong Salt size)
+--FILE--
+<?php
+$salt = '$1$f+uslYF01$';
+$password = 'test';
+echo $salt . "\n";
+echo crypt($password,$salt) . "\n";
+?>
+--EXPECT--
+$1$f+uslYF01$
+$1$f+uslYF0$orVloNmKSLvOeswusE0bY.