diff options
author | Victor Hsieh <victorhsieh@google.com> | 2019-04-15 15:19:08 -0700 |
---|---|---|
committer | Victor Hsieh <victorhsieh@google.com> | 2019-04-15 15:19:08 -0700 |
commit | 17aaee2f053f1fffb52497fb22da5252908a9c75 (patch) | |
tree | 2201e1e3581d19cd799354cf78d2fae7a3483d8a /libkeyutils | |
parent | b142458ab3d251769b0e1f66bf1f31a6ebda6d14 (diff) | |
download | core-17aaee2f053f1fffb52497fb22da5252908a9c75.tar.gz |
mini-keyctl: fix key id parsing by "0x" prefix
Otherwise, ParseInt treats the input as decimal and fails.
Test: add key works
Bug: None
Change-Id: I144ab0bba519c7630e702562bfb54118a389908e
Diffstat (limited to 'libkeyutils')
-rw-r--r-- | libkeyutils/mini_keyctl_utils.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libkeyutils/mini_keyctl_utils.cpp b/libkeyutils/mini_keyctl_utils.cpp index b012a33c6..79b468087 100644 --- a/libkeyutils/mini_keyctl_utils.cpp +++ b/libkeyutils/mini_keyctl_utils.cpp @@ -67,7 +67,7 @@ static key_serial_t GetKeyringIdOrDie(const std::string& keyring_desc) { if (tokens.size() < 9) { continue; } - std::string key_id = tokens[0]; + std::string key_id = "0x" + tokens[0]; std::string key_type = tokens[7]; // The key description may contain space. std::string key_desc_prefix = tokens[8]; @@ -77,7 +77,7 @@ static key_serial_t GetKeyringIdOrDie(const std::string& keyring_desc) { continue; } if (!android::base::ParseInt(key_id.c_str(), &keyring_id)) { - error(1, 0, "Unexpected key format in /proc/keys"); + error(1, 0, "Unexpected key format in /proc/keys: %s", key_id.c_str()); return -1; } return keyring_id; |