Follow up on #8897 but on master which instead does not use the old custom alloca.

Closes #8905.
This commit is contained in:
David Carlier 2022-07-01 12:51:45 +01:00
parent 5bccb64213
commit 0ad8b64b70
3 changed files with 11 additions and 8 deletions

3
NEWS
View file

@ -14,6 +14,9 @@ PHP NEWS
- Sockets:
. Added TCP_CONGESTION socket option. (David Carlier)
- Standard:
. Fixed the crypt_sha256/512 api build with clang > 12. (David Carlier)
- Zip:
. Implement fseek for zip stream when possible with libzip 1.9.1. (Remi)

View file

@ -377,15 +377,15 @@ char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int b
SET_ALLOCA_FLAG(use_heap_key);
SET_ALLOCA_FLAG(use_heap_salt);
if ((key - (char *) 0) % __alignof__ (uint32_t) != 0) {
if ((uintptr_t)key % __alignof__ (uint32_t) != 0) {
tmp_key = (char *) do_alloca(key_len + __alignof__(uint32_t), use_heap_key);
key = copied_key = memcpy(tmp_key + __alignof__(uint32_t) - (tmp_key - (char *) 0) % __alignof__(uint32_t), key, key_len);
key = copied_key = memcpy(tmp_key + __alignof__(uint32_t) - (uintptr_t)tmp_key % __alignof__(uint32_t), key, key_len);
}
if ((salt - (char *) 0) % __alignof__(uint32_t) != 0) {
if ((uintptr_t)salt % __alignof__(uint32_t) != 0) {
tmp_salt = (char *) do_alloca(salt_len + 1 + __alignof__(uint32_t), use_heap_salt);
salt = copied_salt =
memcpy(tmp_salt + __alignof__(uint32_t) - (tmp_salt - (char *) 0) % __alignof__ (uint32_t), salt, salt_len);
memcpy(tmp_salt + __alignof__(uint32_t) - (uintptr_t)tmp_salt % __alignof__ (uint32_t), salt, salt_len);
copied_salt[salt_len] = 0;
}

View file

@ -411,15 +411,15 @@ php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen)
SET_ALLOCA_FLAG(use_heap_key);
SET_ALLOCA_FLAG(use_heap_salt);
if ((key - (char *) 0) % __alignof__ (uint64_t) != 0) {
if ((uintptr_t)key % __alignof__ (uint64_t) != 0) {
tmp_key = (char *) do_alloca(key_len + __alignof__ (uint64_t), use_heap_key);
key = copied_key =
memcpy(tmp_key + __alignof__(uint64_t) - (tmp_key - (char *) 0) % __alignof__(uint64_t), key, key_len);
memcpy(tmp_key + __alignof__(uint64_t) - (uintptr_t)tmp_key % __alignof__(uint64_t), key, key_len);
}
if ((salt - (char *) 0) % __alignof__ (uint64_t) != 0) {
if ((uintptr_t)salt % __alignof__ (uint64_t) != 0) {
tmp_salt = (char *) do_alloca(salt_len + 1 + __alignof__(uint64_t), use_heap_salt);
salt = copied_salt = memcpy(tmp_salt + __alignof__(uint64_t) - (tmp_salt - (char *) 0) % __alignof__(uint64_t), salt, salt_len);
salt = copied_salt = memcpy(tmp_salt + __alignof__(uint64_t) - (uintptr_t)tmp_salt % __alignof__(uint64_t), salt, salt_len);
copied_salt[salt_len] = 0;
}