Fix up lifetime handling of SecItemCopyMatching result parameter - #15468
Conversation
Docs state it's caller retained via Create rule
| if (status == SecStatusCode.Success){ | ||
| if (max == 1) | ||
| return new NSData [] { Runtime.GetNSObject<NSData> (ptr, false)! }; | ||
| return new NSData [] { Runtime.GetNSObject<NSData> (ptr, true)! }; |
There was a problem hiding this comment.
Not sure what this is supposed to do.
There was a problem hiding this comment.
To rephrase, it's possible that because we're not looking at this as a container of NSData, we would leak the other elements.
There was a problem hiding this comment.
The native function is weird: it only returns an array if the limit is > 1:
"By default, this function returns only the first match found. To obtain more than one matching item at a time, specify the search key kSecMatchLimit with a value greater than 1. The result will be an object of type CFArrayRef containing up to that number of matching items."
This means the code is good as-is.
|
It fails to compile: |
My vim fu is rusty, I accidentally |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💻 [PR Build] Tests on macOS Mac Catalina (10.15) passed 💻✅ All tests on macOS Mac Catalina (10.15) passed. Pipeline on Agent |
✅ API diff for current PR / commitLegacy Xamarin (No breaking changes).NET (No breaking changes)✅ API diff vs stableLegacy Xamarin (No breaking changes).NET (No breaking changes)✅ Generator diffGenerator diff is empty Pipeline on Agent |
❌ [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌Failed tests are:
Pipeline on Agent |
🚀 [CI Build] Test results 🚀Test results✅ All tests passed on VSTS: simulator tests. 🎉 All 223 tests passed 🎉 Tests counts✅ bcl: All 69 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
| if (status == SecStatusCode.Success){ | ||
| if (max == 1) | ||
| return new NSData [] { Runtime.GetNSObject<NSData> (ptr, false)! }; | ||
| return new NSData [] { Runtime.GetNSObject<NSData> (ptr, true)! }; |
There was a problem hiding this comment.
The native function is weird: it only returns an array if the limit is > 1:
"By default, this function returns only the first match found. To obtain more than one matching item at a time, specify the search key kSecMatchLimit with a value greater than 1. The result will be an object of type CFArrayRef containing up to that number of matching items."
This means the code is good as-is.
Docs state it's caller retained via Create rule