Hi!

On 7/19/11 4:44 PM, Solar Designer wrote:
Hi,

These tests fail in trunk on my x86_64 build:

crypt_sha256.phpt
crypt_variation1.phpt

The differences are like this:

Expected:<$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5>
Got<$5$saltst$JTS/fkywz8NvjeCGmWDndJPi7ZrRFhQKBLNtQZWE2C3>

That is, the salts are truncated.  There's a relevant recent change in
crypt.c involving the line:

                salt_in_len = MIN(PHP_MAX_SALT_LEN, salt_in_len);


Thanks for the report.
This problem seems to be unrelated to this change, but in fact looks like it's related to this code in

        if ((salt - (char *) 0) % __alignof__(uint32_t) != 0) {
                char *tmp = (char *) alloca(salt_len + 1 + 
__alignof__(uint32_t));
                salt = copied_salt =
memcpy(tmp + __alignof__(uint32_t) - (tmp - (char *) 0) % __alignof__ (uint32_t), salt, salt_len);
                tmp[salt_len] = 0;
        }

As you can see, the last line cuts the string relative to tmp, but salt is copied to tmp with offest, which leads to salt truncation. Changing it from tmp to copied_salt seems to fix the problem. I'll apply the fix in a minute.
The change that introduced this problem is:
http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/ext/standard/crypt_sha256.c?r1=300427&r2=312952

--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to