Closed mshibanami closed 2 years ago
I'm seeing the same crash in our app
Hi @mshibanami, I'm sorry, I totally missed your PR. I'll release new version with a fix next week. Thank you and sorry again.
No problems, thanks!
Hi @mshibanami,
Thanks again for PR, I've reviewed the code and found it similar to the code I got from Apple Technical Support Team a while ago. I've pushed the implementation on master branch and going to release it in a few.
I appreciate the time you’ve taken to fix this issue and thanks again for bringing it up.
Oh sorry @tikhop, I didn't track this PR since I personally resolved the issue. I tried the latest version and then it worked great for me. Thanks so much! By the way, thanks to your work, I released my macOS app. I'm now porting it to iOS and this library works great on iOS too. Thanks heaps. 🙂
Hi,
I noticed that TPInAppReceipt crashes an app when verifying a receipt's hash with
InAppReceipt
'sverifyHash()
on a Mac that has noen0
for its Ethernet/Wi-Fi. This PR is for fixing it.Problem details
Currently, TPInAppReceipt makes the app crash on some Macs because of this line (
guidData
isnil
):https://github.com/tikhop/TPInAppReceipt/blob/22d7d92/Sources/Validation.swift#L329
I confirmed that the crash is caused because some machines have
en1
rather thanen0
for their Ethernet/Wi-Fi interface. So TPInAppReceipt actually needs to checken1
in this line for them:https://github.com/tikhop/TPInAppReceipt/blob/22d7d92/Sources/Validation.swift#L283
Otherwise,
iterator
becomes0
(IO_OBJECT_NULL
).Implementation
With the change of this PR, TPInAppReceipt checks a builtin
en1
and a non-builtinen0
as fallback interfaces. I got most code from here, then reformatted it to align the style with the code base: https://developer.apple.com/documentation/appstorereceipts/validating_receipts_on_the_deviceAlso, I changed the type of the return value of
uuid()
toData?
so that no potential crashes anymore.I tested this change with built-in
en0
and build-inen1
but sorry, I couldn't test it for non built-inen0
since I have no Mac like that but it should work fine.This library helps my life a lot. Thanks so much for maintaining it!