setAddress.clear() without a lock in CCryptoKeyStore::GetKeys and CBasicKeyStore::GetKeys #10905

issue lyle-nel opened this issue on July 22, 2017
  1. lyle-nel commented at 9:59 AM on July 22, 2017: none

    <!--- Remove sections that do not apply -->

    Describe the issue

    CCryptoKeyStore::GetKeys at line 173 of file src/wallet/crypter.h and CBasicKeyStore::GetKeys at line 75 of file src/keystore.h call setAddress.clear(); without a lock.

    What version of bitcoin-core are you using?

    Master branch:0c173a15ca1bf20999f74987988985508c9de463

  2. benma commented at 8:10 PM on July 23, 2017: none

    If it needs to be locked, then at the callsite, not in the caller.

    However, it doesn't need to be locked. The only callsite is wallet.cpp:3664, where the variable is a local stack variable, so there is no thread-safety issue.

    The setAddress.clear(); line doesn't do anything meaningful either (the passed set is already empty). We could think about returning the result directly instead of passing it by reference to avoid the clear() and also to make it more clear that locking isn't needed there.

    Edit: a lock seems to be missing though from crypter.h, GetKeys(), but not for setAddress.clear(), but for looping through mapCryptedKeys.

  3. benma referenced this in commit 5cb3da04b8 on Jul 23, 2017
  4. benma referenced this in commit fe09b0197c on Jul 23, 2017
  5. lyle-nel closed this on Jul 24, 2017

  6. laanwj referenced this in commit e6ab88a452 on Sep 7, 2017
  7. fanquake referenced this in commit 5486fe58af on Sep 10, 2017
  8. fanquake referenced this in commit 7a1f6f1ff2 on Sep 10, 2017
  9. HashUnlimited referenced this in commit db75a583b1 on Mar 10, 2018
  10. HashUnlimited referenced this in commit aea371da69 on Mar 10, 2018
  11. PastaPastaPasta referenced this in commit bd15d75b5f on Sep 23, 2019
  12. PastaPastaPasta referenced this in commit cacb81c34e on Dec 21, 2019
  13. PastaPastaPasta referenced this in commit 1781c7e4fe on Jan 2, 2020
  14. PastaPastaPasta referenced this in commit e97e8e199f on Jan 4, 2020
  15. PastaPastaPasta referenced this in commit 07704e56d1 on Jan 4, 2020
  16. PastaPastaPasta referenced this in commit d3b6c0dff6 on Jan 10, 2020
  17. PastaPastaPasta referenced this in commit 3884cfb3af on Jan 10, 2020
  18. PastaPastaPasta referenced this in commit d7a2232103 on Jan 10, 2020
  19. PastaPastaPasta referenced this in commit 3af9698d27 on Jan 12, 2020
  20. ckti referenced this in commit 44d3a64228 on Mar 28, 2021
  21. gades referenced this in commit 89b1ebbc51 on Jun 30, 2021
  22. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-15 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me