becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

[iOS] Crash, if service txtRecordData is malformed #32

Closed fishkingsin closed 5 years ago

fishkingsin commented 7 years ago

I have a device broadcasting null value dictionary cause crashed in https://github.com/becvert/cordova-plugin-zeroconf/blob/master/src/ios/ZeroConf.swift#L354

becvert commented 7 years ago

ok. does it work on Android?

fishkingsin commented 7 years ago

it is ios specific issue have not tried on android

becvert commented 7 years ago

Please test version 2.1.4

fishkingsin commented 7 years ago

I found that in txtRecordData is raw byte data to translate it to dictionary it need a proper key,value pair format

but some of my device boardcasted

Optional("\u{0E}isPaired=false\u{0C}serialNumber\rmodel=MODEL_NAME")

serialNumber(key) was wrong format "=" is missing "value" is missing

becvert commented 7 years ago

so txtRecordData returns some data but it is malformed key/value pairs?

are you able to do a quick check on android too? that would be nice.

becvert commented 7 years ago

Does it still crash the app by the way?

fishkingsin commented 7 years ago

it will crash seem NSDictionary could not parse the malformed data

becvert commented 7 years ago

NetService.dictionary fails an assertion if txtData cannot be represented as an NSDictionary object

failed assertions terminate the app in debug for sure, but maybe not in production. @fishkingsin , does it crash in production?

if it does, the problem is in Swift you cannot catch a failed assertion. that means we need to parse ourselves the data. I do not want to do that.

fishkingsin commented 7 years ago

@becvert thanks for the comment, I will trying to fix that

becvert commented 7 years ago

What's the status on this @fishkingsin

fishkingsin commented 7 years ago

I think it only happen from my case, ios + melform txtData I have no idea how to fix that

becvert commented 7 years ago

No worries. I'll have another look later on.

fishkingsin commented 7 years ago

some finding https://stackoverflow.com/questions/40193911/nsnetservice-dictionaryfromtxtrecord-fails-an- assertion-on-invalid-input

certabitmh commented 6 years ago

any news on that?

becvert commented 5 years ago

Nope. Closing old issue. Feel free to reopen.