becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

Validate data before calling NetService.dictionary #86

Closed digaus closed 4 years ago

digaus commented 4 years ago

This prevents the crash of the app when a broadcast has the wrong format

https://github.com/becvert/cordova-plugin-zeroconf/issues/85 https://github.com/becvert/cordova-plugin-zeroconf/issues/79 https://github.com/becvert/cordova-plugin-zeroconf/issues/32

emcniece commented 4 years ago

Thank you for hunting this down!

What iOS versions have you tested this on? I'm not sure exactly how far back we need (or want) to support, but it would be good to know that it works on latest - 1 at least.

Any chance you have a link to the txtRecordData spec handy? How has the record format changed in such a way that breaks the original parsing?

digaus commented 4 years ago

Thanks for the fast response :) I tested it on 13.3 iPadOS and a user successfully tested on 13.3 iOS.

Have no other devices on hand to do more testing. The code I use is from here:

https://stackoverflow.com/a/52220739

Another solution would be to use the Objective C call:

https://stackoverflow.com/a/41371961

digaus commented 4 years ago

@emcniece

Valid questions but I cannot answer any of that, I have no experience in swift and just searched the issue until I found someone who ran into that aswell.

You might find a better solution since we now know why the crash happens. I can do some testing on what responses I get for the 'textRecord'.

Might also try this possible fix: https://stackoverflow.com/a/40473424

It only checks for correctness and then calls the initial method.

emcniece commented 4 years ago

Tested, debugged, and approved. I'd like to add some text to the fatalError() call but I'll do that in the next PR.

Thank you so much for helping us fix this!