Fixed bug relating to un-initialized memory access

This commit is contained in:
Ilia Alshanetsky 2011-07-05 20:10:45 +00:00
parent 5842a4147f
commit 1a4456bb76
2 changed files with 4 additions and 3 deletions

View File

@ -395,9 +395,10 @@ char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int b
}
if ((salt - (char *) 0) % __alignof__(uint32_t) != 0) {
char *tmp = (char *) alloca(salt_len + __alignof__(uint32_t));
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;
}
/* Prepare for the real work. */

View File

@ -430,8 +430,8 @@ php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen)
}
if ((salt - (char *) 0) % __alignof__ (uint64_t) != 0) {
char *tmp = (char *) alloca(salt_len + __alignof__(uint64_t));
char *tmp = (char *) alloca(salt_len + 1 + __alignof__(uint64_t));
tmp[salt_len] = 0;
salt = copied_salt = memcpy(tmp + __alignof__(uint64_t) - (tmp - (char *) 0) % __alignof__(uint64_t), salt, salt_len);
}