summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2011-07-05 20:10:45 +0000
committerIlia Alshanetsky <iliaa@php.net>2011-07-05 20:10:45 +0000
commit3c82aab1518e321e560cc6daedf1c698741fb861 (patch)
treec66859bf9bd3ce45508cab00eba60702e4210ad0 /ext
parentaf84289663a5c4a0bcee7a2ac7285bbcb4c385af (diff)
downloadphp-git-3c82aab1518e321e560cc6daedf1c698741fb861.tar.gz
Fixed bug relating to un-initialized memory access
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/crypt_sha256.c3
-rw-r--r--ext/standard/crypt_sha512.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/ext/standard/crypt_sha256.c b/ext/standard/crypt_sha256.c
index 26260992ef..231206bca1 100644
--- a/ext/standard/crypt_sha256.c
+++ b/ext/standard/crypt_sha256.c
@@ -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. */
diff --git a/ext/standard/crypt_sha512.c b/ext/standard/crypt_sha512.c
index a51e11a37c..708ad67caa 100644
--- a/ext/standard/crypt_sha512.c
+++ b/ext/standard/crypt_sha512.c
@@ -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);
}