Skip to content

Commit 826ca28

Browse files
committed
- Fixed #50052, Different Hashes on Windows and Linux on wrong Salt size
1 parent 574b088 commit 826ca28

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

ext/standard/php_crypt_r.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ char * php_md5_crypt_r(const char *pw, const char *salt, char *out) {
208208
if (strncpy_s(passwd + MD5_MAGIC_LEN, MD5_HASH_MAX_LEN - MD5_MAGIC_LEN, sp, sl + 1) != 0) {
209209
goto _destroyCtx1;
210210
}
211+
passwd[MD5_MAGIC_LEN + sl] = '\0';
211212
strcat_s(passwd, MD5_HASH_MAX_LEN, "$");
212213
#else
213214
/* VC6 version doesn't have strcat_s or strncpy_s */
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #50052 (Different Hashes on Windows and Linux on wrong Salt size)
3+
--FILE--
4+
<?php
5+
$salt = '$1$f+uslYF01$';
6+
$password = 'test';
7+
echo $salt . "\n";
8+
echo crypt($password,$salt) . "\n";
9+
?>
10+
--EXPECT--
11+
$1$f+uslYF01$
12+
$1$f+uslYF0$orVloNmKSLvOeswusE0bY.

0 commit comments

Comments
 (0)