New issue
Advanced search Search tips

Issue 834021 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: iOS
Pri: 2
Type: Bug



Sign in to add a comment

[CRD iOS][Static Analysis] Leaky CFString and CFData wrapper at RemotingKeychain

Project Member Reported by yuweih@chromium.org, Apr 17 2018

Issue description

While the content of the string/data is not managed by ref-counting, the CFStringRef and CFDataRef themselves still need to be released.


../../remoting/ios/persistence/remoting_keychain.cc:48:24: warning: Potential leak of an object
  CFDictionarySetValue(dictionary.get(), kSecAttrAccount,
                       ^
../../remoting/ios/persistence/remoting_keychain.cc:140:35: note: Calling 'CreateQueryForUpdate'
  ScopedMutableDictionary query = CreateQueryForUpdate(service, account);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:47:24: note: Calling 'WrapStdString'
                       WrapStdString(service));
                       ^~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:25:10: note: Call to function 'CFStringCreateWithCStringNoCopy' returns a Core Foundation object of type CFStringRef with a +1 retain count
  return CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, str.c_str(),
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:47:24: note: Returning from 'WrapStdString'
                       WrapStdString(service));
                       ^~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:48:24: note: Object leaked: allocated object is not referenced later in this execution path and has a retain count of +1
  CFDictionarySetValue(dictionary.get(), kSecAttrAccount,
                       ^~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:51:10: warning: Potential leak of an object
  return dictionary;
         ^
../../remoting/ios/persistence/remoting_keychain.cc:140:35: note: Calling 'CreateQueryForUpdate'
  ScopedMutableDictionary query = CreateQueryForUpdate(service, account);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:49:24: note: Calling 'WrapStdString'
                       WrapStdString(account));
                       ^~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:25:10: note: Call to function 'CFStringCreateWithCStringNoCopy' returns a Core Foundation object of type CFStringRef with a +1 retain count
  return CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, str.c_str(),
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:49:24: note: Returning from 'WrapStdString'
                       WrapStdString(account));
                       ^~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:51:10: note: Object leaked: allocated object is not referenced later in this execution path and has a retain count of +1
  return dictionary;
         ^~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:67:10: warning: Potential leak of an object
  return dictionary;
         ^
../../remoting/ios/persistence/remoting_keychain.cc:90:7: note: Assuming the condition is false
  if (!existing_data.empty()) {
      ^~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:90:3: note: Taking false branch
  if (!existing_data.empty()) {
  ^
../../remoting/ios/persistence/remoting_keychain.cc:109:7: note: Calling 'CreateDictionaryForInsertion'
      CreateDictionaryForInsertion(service, account, data);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:66:57: note: Calling 'WrapStringToData'
  CFDictionarySetValue(dictionary.get(), kSecValueData, WrapStringToData(data));
                                                        ^~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:32:10: note: Call to function 'CFDataCreateWithBytesNoCopy' returns a Core Foundation object of type CFDataRef with a +1 retain count
  return CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, data_pointer,
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:66:57: note: Returning from 'WrapStringToData'
  CFDictionarySetValue(dictionary.get(), kSecValueData, WrapStringToData(data));
                                                        ^~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:67:10: note: Object leaked: allocated object is not referenced later in this execution path and has a retain count of +1
  return dictionary;
         ^~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:100:37: warning: Potential leak of an object
    OSStatus status = SecItemUpdate(update_query, updated_attributes);
                                    ^~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:90:7: note: Assuming the condition is true
  if (!existing_data.empty()) {
      ^~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:90:3: note: Taking true branch
  if (!existing_data.empty()) {
  ^
../../remoting/ios/persistence/remoting_keychain.cc:99:26: note: Calling 'WrapStringToData'
                         WrapStringToData(data));
                         ^~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:32:10: note: Call to function 'CFDataCreateWithBytesNoCopy' returns a Core Foundation object of type CFDataRef with a +1 retain count
  return CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, data_pointer,
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:99:26: note: Returning from 'WrapStringToData'
                         WrapStringToData(data));
                         ^~~~~~~~~~~~~~~~~~~~~~
../../remoting/ios/persistence/remoting_keychain.cc:100:37: note: Object leaked: allocated object is not referenced later in this execution path and has a retain count of +1
    OSStatus status = SecItemUpdate(update_query, updated_attributes);
                                    ^~~~~~~~~~~~
4 warnings generated.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Apr 17 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/c028052bb3ae0578afd280925e5de08d61d70ac4

commit c028052bb3ae0578afd280925e5de08d61d70ac4
Author: Yuwei Huang <yuweih@chromium.org>
Date: Tue Apr 17 21:26:33 2018

[CRD iOS] Fix leaky CFString and CFData wrappers

Currently we create CFString and CFData wrappers for the underlying
std::string in RemotingKeychain. Even though the underlying content
isn't managed or released by the wrapper, we still need to release the
wrapper itself.

Bug:  834021 
Change-Id: I47b298dc9a06ce34de68442cddc7ff07e79c0873
Reviewed-on: https://chromium-review.googlesource.com/1015769
Reviewed-by: Jamie Walch <jamiewalch@chromium.org>
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551481}
[modify] https://crrev.com/c028052bb3ae0578afd280925e5de08d61d70ac4/remoting/ios/persistence/remoting_keychain.cc

Comment 2 by yuweih@chromium.org, Apr 17 2018

Labels: Merge-Request-67
This only affects Chromoting and doesn't affect Chrome.
Project Member

Comment 3 by sheriffbot@chromium.org, Apr 18 2018

Labels: -Merge-Request-67 Merge-Approved-67 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M67. Please go ahead and merge the CL to branch 3396 manually. Please contact milestone owner if you have questions.
Owners: cmasso@(Android), cmasso@(iOS), kbleicher@(ChromeOS), govind@(Desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 4 by bugdroid1@chromium.org, Apr 18 2018

Labels: -merge-approved-67 merge-merged-3396
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3d6ce98382a20f3731344c7370663aed54c15dfd

commit 3d6ce98382a20f3731344c7370663aed54c15dfd
Author: Yuwei Huang <yuweih@chromium.org>
Date: Wed Apr 18 22:21:32 2018

[CRD iOS] Fix leaky CFString and CFData wrappers

Currently we create CFString and CFData wrappers for the underlying
std::string in RemotingKeychain. Even though the underlying content
isn't managed or released by the wrapper, we still need to release the
wrapper itself.

Bug:  834021 
Change-Id: I47b298dc9a06ce34de68442cddc7ff07e79c0873
Reviewed-on: https://chromium-review.googlesource.com/1015769
Reviewed-by: Jamie Walch <jamiewalch@chromium.org>
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#551481}(cherry picked from commit c028052bb3ae0578afd280925e5de08d61d70ac4)
Reviewed-on: https://chromium-review.googlesource.com/1018043
Reviewed-by: Yuwei Huang <yuweih@chromium.org>
Cr-Commit-Position: refs/branch-heads/3396@{#109}
Cr-Branched-From: 9ef2aa869bc7bc0c089e255d698cca6e47d6b038-refs/heads/master@{#550428}
[modify] https://crrev.com/3d6ce98382a20f3731344c7370663aed54c15dfd/remoting/ios/persistence/remoting_keychain.cc

Comment 5 by yuweih@chromium.org, Apr 18 2018

Status: Fixed (was: Assigned)

Sign in to add a comment