Skip to content

Commit 6876c20

Browse files
committed
Merge branch 'PHP-8.1'
2 parents a193427 + 26d63c7 commit 6876c20

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ PHP NEWS
1010
- Sockets:
1111
. Added TCP_CONGESTION socket option. (David Carlier)
1212

13+
- Standard:
14+
. Fixed the crypt_sha256/512 api build with clang > 12. (David Carier)
15+
1316
- Zip:
1417

1518
. Implement fseek for zip stream when possible with libzip 1.9.1. (Remi)

ext/standard/crypt_sha256.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,15 +377,15 @@ char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int b
377377
SET_ALLOCA_FLAG(use_heap_key);
378378
SET_ALLOCA_FLAG(use_heap_salt);
379379

380-
if ((key - (char *) 0) % __alignof__ (uint32_t) != 0) {
381-
tmp_key = (char *) do_alloca(key_len + __alignof__(uint32_t), use_heap_key);
382-
key = copied_key = memcpy(tmp_key + __alignof__(uint32_t) - (tmp_key - (char *) 0) % __alignof__(uint32_t), key, key_len);
380+
if ((uintptr_t)key % __alignof__ (uint32_t) != 0) {
381+
char *tmp = (char *) do_alloca(key_len + __alignof__(uint32_t), use_heap_key);
382+
key = copied_key = memcpy(tmp + __alignof__(uint32_t) - (uintptr_t)tmp % __alignof__(uint32_t), key, key_len);
383383
}
384384

385-
if ((salt - (char *) 0) % __alignof__(uint32_t) != 0) {
386-
tmp_salt = (char *) do_alloca(salt_len + 1 + __alignof__(uint32_t), use_heap_salt);
385+
if ((uintptr_t)salt % __alignof__(uint32_t) != 0) {
386+
char *tmp = (char *) do_alloca(salt_len + 1 + __alignof__(uint32_t), use_heap_salt);
387387
salt = copied_salt =
388-
memcpy(tmp_salt + __alignof__(uint32_t) - (tmp_salt - (char *) 0) % __alignof__ (uint32_t), salt, salt_len);
388+
memcpy(tmp + __alignof__(uint32_t) - (uintptr_t)tmp % __alignof__ (uint32_t), salt, salt_len);
389389
copied_salt[salt_len] = 0;
390390
}
391391

ext/standard/crypt_sha512.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,15 @@ php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen)
411411
SET_ALLOCA_FLAG(use_heap_key);
412412
SET_ALLOCA_FLAG(use_heap_salt);
413413

414-
if ((key - (char *) 0) % __alignof__ (uint64_t) != 0) {
415-
tmp_key = (char *) do_alloca(key_len + __alignof__ (uint64_t), use_heap_key);
414+
if ((uintptr_t)key % __alignof__ (uint64_t) != 0) {
415+
char *tmp = (char *) do_alloca (key_len + __alignof__ (uint64_t), use_heap_key);
416416
key = copied_key =
417-
memcpy(tmp_key + __alignof__(uint64_t) - (tmp_key - (char *) 0) % __alignof__(uint64_t), key, key_len);
417+
memcpy(tmp + __alignof__(uint64_t) - (uintptr_t)tmp % __alignof__(uint64_t), key, key_len);
418418
}
419419

420-
if ((salt - (char *) 0) % __alignof__ (uint64_t) != 0) {
421-
tmp_salt = (char *) do_alloca(salt_len + 1 + __alignof__(uint64_t), use_heap_salt);
422-
salt = copied_salt = memcpy(tmp_salt + __alignof__(uint64_t) - (tmp_salt - (char *) 0) % __alignof__(uint64_t), salt, salt_len);
420+
if ((uintptr_t)salt % __alignof__ (uint64_t) != 0) {
421+
char *tmp = (char *) do_alloca(salt_len + 1 + __alignof__(uint64_t), use_heap_salt);
422+
salt = copied_salt = memcpy(tmp + __alignof__(uint64_t) - (uintptr_t)tmp % __alignof__(uint64_t), salt, salt_len);
423423
copied_salt[salt_len] = 0;
424424
}
425425

0 commit comments

Comments
 (0)