Skip to content

Commit b5dabad

Browse files
committed
Follow up on php#8897 but on master which instead does not
use the old custom alloca.
1 parent 40908b1 commit b5dabad

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

ext/standard/crypt_sha256.c

Lines changed: 4 additions & 4 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) {
380+
if ((uintptr_t)key % __alignof__ (uint32_t) != 0) {
381381
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);
382+
key = copied_key = memcpy(tmp_key + __alignof__(uint32_t) - (uintptr_t)tmp_key % __alignof__(uint32_t), key, key_len);
383383
}
384384

385-
if ((salt - (char *) 0) % __alignof__(uint32_t) != 0) {
385+
if ((uintptr_t)salt % __alignof__(uint32_t) != 0) {
386386
tmp_salt = (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_salt + __alignof__(uint32_t) - (uintptr_t)tmp_salt % __alignof__ (uint32_t), salt, salt_len);
389389
copied_salt[salt_len] = 0;
390390
}
391391

ext/standard/crypt_sha512.c

Lines changed: 4 additions & 4 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) {
414+
if ((uintptr_t)key % __alignof__ (uint64_t) != 0) {
415415
tmp_key = (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_key + __alignof__(uint64_t) - (uintptr_t)tmp_key % __alignof__(uint64_t), key, key_len);
418418
}
419419

420-
if ((salt - (char *) 0) % __alignof__ (uint64_t) != 0) {
420+
if ((uintptr_t)salt % __alignof__ (uint64_t) != 0) {
421421
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);
422+
salt = copied_salt = memcpy(tmp_salt + __alignof__(uint64_t) - (uintptr_t)tmp_salt % __alignof__(uint64_t), salt, salt_len);
423423
copied_salt[salt_len] = 0;
424424
}
425425

0 commit comments

Comments
 (0)