• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/core


Commit MetaInfo

Revisionda6c753a2bbc2b2e5a8809250a38f3fc2019d365 (tree)
Time2019-07-12 04:08:54
AuthorJanis Danisevskis <jdanis@goog...>
CommiterArjun Garg

Log Message

Fix a memory leak in gatekeeper.

In violation to the documentation of GateKeeper::GetAuthTokenKey and
GateKeeper::GetPasswordKey, the implementations in SoftGateKeeper
allocate and return buffers and relinquish ownership causing a memory
leak, because the caller expects the implementation to retain ownership.

Bug: 129768470
Bug: 134557251
Test: gatekeeper-unit-tests
Change-Id: I0af9539d3dcd47dfd1e7d80cdee700ea0c2d6d0f
Merged-In: I0af9539d3dcd47dfd1e7d80cdee700ea0c2d6d0f
(cherry picked from commit 6a9c4e7968e73393110b169b33fb636531fe7fc2)

Change Summary

Incremental Difference

--- a/gatekeeperd/SoftGateKeeper.h
+++ b/gatekeeperd/SoftGateKeeper.h
@@ -58,23 +58,16 @@ public:
5858 virtual ~SoftGateKeeper() {
5959 }
6060
61- virtual bool GetAuthTokenKey(const uint8_t **auth_token_key,
62- uint32_t *length) const {
61+ virtual bool GetAuthTokenKey(const uint8_t** auth_token_key, uint32_t* length) const {
6362 if (auth_token_key == NULL || length == NULL) return false;
64- uint8_t *auth_token_key_copy = new uint8_t[SIGNATURE_LENGTH_BYTES];
65- memcpy(auth_token_key_copy, key_.get(), SIGNATURE_LENGTH_BYTES);
66-
67- *auth_token_key = auth_token_key_copy;
63+ *auth_token_key = key_.get();
6864 *length = SIGNATURE_LENGTH_BYTES;
6965 return true;
7066 }
7167
72- virtual void GetPasswordKey(const uint8_t **password_key, uint32_t *length) {
68+ virtual void GetPasswordKey(const uint8_t** password_key, uint32_t* length) {
7369 if (password_key == NULL || length == NULL) return;
74- uint8_t *password_key_copy = new uint8_t[SIGNATURE_LENGTH_BYTES];
75- memcpy(password_key_copy, key_.get(), SIGNATURE_LENGTH_BYTES);
76-
77- *password_key = password_key_copy;
70+ *password_key = key_.get();
7871 *length = SIGNATURE_LENGTH_BYTES;
7972 }
8073