summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrahmaji K <bkomma@codeaurora.org>2017-04-24 07:32:15 (GMT)
committerBruno Martins <bgcngm@gmail.com>2017-06-01 15:19:37 (GMT)
commitda6e595c73cf7c8c45d5933ce0f2efe50229cf33 (patch)
tree7010957cf723ebf464a527bb015039367577fc5d
parent144e832ff3e16af20d3975aeec4a64bf8f80a8a3 (diff)
downloadandroid_vendor_qcom_opensource_cryptfs_hw-da6e595c73cf7c8c45d5933ce0f2efe50229cf33.zip
android_vendor_qcom_opensource_cryptfs_hw-da6e595c73cf7c8c45d5933ce0f2efe50229cf33.tar.gz
android_vendor_qcom_opensource_cryptfs_hw-da6e595c73cf7c8c45d5933ce0f2efe50229cf33.tar.bz2
cryptfs_hw: Fix stack out of bound issuerefs/changes/63/175463/1
Add strnlen() instead of strlen() to fix the buffer overflow while processing the password. Change-Id: I5996bb62980741b7463c8829a43524e79abc4f19
-rwxr-xr-xcryptfs_hw.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/cryptfs_hw.c b/cryptfs_hw.c
index ff06c9f..214713c 100755
--- a/cryptfs_hw.c
+++ b/cryptfs_hw.c
@@ -106,7 +106,7 @@ static unsigned char* get_tmp_passwd(const char* passwd)
tmp_passwd = (unsigned char*)malloc(MAX_PASSWORD_LEN);
if(tmp_passwd) {
memset(tmp_passwd, 0, MAX_PASSWORD_LEN);
- passwd_len = (strlen(passwd) > MAX_PASSWORD_LEN) ? MAX_PASSWORD_LEN : strlen(passwd);
+ passwd_len = strnlen(passwd, MAX_PASSWORD_LEN);
memcpy(tmp_passwd, passwd, passwd_len);
} else {
SLOGE("%s: Failed to allocate memory for tmp passwd \n", __func__);