From 392c4dbdc1a0220f35d5c34d5c61f8a8197d175f Mon Sep 17 00:00:00 2001 From: Yong Yao Date: Wed, 5 Apr 2017 05:52:48 -0400 Subject: [PATCH] Fix keyname generation issue The keyname binded to keyring return a wrong string when there are binary char larger than 127, the sign extension will introduce unexpect FFFFFF string to the keyname. Bug: 36975893 Test: local build Change-Id: Iba2f6ef95aeacd08c8d6c72b71e7b92e956ec3fc Signed-off-by: Ai, Ting A --- Ext4Crypt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ext4Crypt.cpp b/Ext4Crypt.cpp index 88bedd0..83141d1 100644 --- a/Ext4Crypt.cpp +++ b/Ext4Crypt.cpp @@ -137,7 +137,7 @@ static bool fill_key(const std::string& key, ext4_encryption_key* ext4_key) { static std::string keyname(const std::string& raw_ref) { std::ostringstream o; o << "ext4:"; - for (auto i : raw_ref) { + for (unsigned char i : raw_ref) { o << std::hex << std::setw(2) << std::setfill('0') << (int)i; } return o.str();