Skip to content

Commit 3bf0943

Browse files
committed
Use seperate use heap variables from s and p byte sequences
1 parent ba7aa6c commit 3bf0943

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

ext/standard/crypt_sha256.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,8 @@ char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int b
446446
sha256_finish_ctx(&alt_ctx, temp_result);
447447

448448
/* Create byte sequence P. */
449-
cp = p_bytes = do_alloca(key_len, use_heap_key);
449+
ALLOCA_FLAG(use_heap_p_bytes);
450+
cp = p_bytes = do_alloca(key_len, use_heap_p_bytes);
450451
for (cnt = key_len; cnt >= 32; cnt -= 32) {
451452
cp = __php_mempcpy((void *)cp, (const void *)temp_result, 32);
452453
}
@@ -464,7 +465,8 @@ char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int b
464465
sha256_finish_ctx(&alt_ctx, temp_result);
465466

466467
/* Create byte sequence S. */
467-
cp = s_bytes = do_alloca(salt_len, use_heap_salt);
468+
ALLOCA_FLAG(use_heap_s_bytes);
469+
cp = s_bytes = do_alloca(salt_len, use_heap_s_bytes);
468470
for (cnt = salt_len; cnt >= 32; cnt -= 32) {
469471
cp = __php_mempcpy(cp, temp_result, 32);
470472
}
@@ -580,8 +582,8 @@ char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int b
580582
if (tmp_salt != NULL) {
581583
free_alloca(tmp_salt, use_heap_salt);
582584
}
583-
free_alloca(p_bytes, use_heap_key);
584-
free_alloca(s_bytes, use_heap_salt);
585+
free_alloca(p_bytes, use_heap_p_bytes);
586+
free_alloca(s_bytes, use_heap_s_bytes);
585587

586588
return buffer;
587589
}

ext/standard/crypt_sha512.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,8 @@ php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen)
480480
sha512_finish_ctx(&alt_ctx, temp_result);
481481

482482
/* Create byte sequence P. */
483-
cp = p_bytes = do_alloca(key_len, use_heap_key);
483+
ALLOCA_FLAG(use_heap_p_bytes);
484+
cp = p_bytes = do_alloca(key_len, use_heap_p_bytes);
484485
for (cnt = key_len; cnt >= 64; cnt -= 64) {
485486
cp = __php_mempcpy((void *) cp, (const void *)temp_result, 64);
486487
}
@@ -499,7 +500,8 @@ php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen)
499500
sha512_finish_ctx(&alt_ctx, temp_result);
500501

501502
/* Create byte sequence S. */
502-
cp = s_bytes = do_alloca(salt_len, use_heap_salt);
503+
ALLOCA_FLAG(use_heap_s_bytes);
504+
cp = s_bytes = do_alloca(salt_len, use_heap_s_bytes);
503505
for (cnt = salt_len; cnt >= 64; cnt -= 64) {
504506
cp = __php_mempcpy(cp, temp_result, 64);
505507
}
@@ -627,8 +629,8 @@ php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen)
627629
if (tmp_salt != NULL) {
628630
free_alloca(tmp_salt, use_heap_salt);
629631
}
630-
free_alloca(p_bytes, use_heap_key);
631-
free_alloca(s_bytes, use_heap_salt);
632+
free_alloca(p_bytes, use_heap_p_bytes);
633+
free_alloca(s_bytes, use_heap_s_bytes);
632634

633635
return buffer;
634636
}

0 commit comments

Comments
 (0)