emqx / CocoaMQTT

MQTT 5.0 client library for iOS and macOS written in Swift
https://www.emqx.com/en
Other
1.6k stars 419 forks source link

Fixed Crash issue #506

Closed sadarm closed 1 year ago

sadarm commented 1 year ago

I fixed a crash that occurred when a 'ConnectReturnCode' of 7 or higher was received.

If a ConnectReturnCode of 7 or higher is received, the returnCode of FrameConnAck becomes nil, which is a crash caused by incorrect access to the returnCode afterward.

https://github.com/emqx/CocoaMQTT/blob/1d53567bee10083c72a8f6155ccd837d686898cd/Source/CocoaMQTT.swift#L15-L23

https://github.com/emqx/CocoaMQTT/blob/1d53567bee10083c72a8f6155ccd837d686898cd/Source/FrameConnAck.swift#L97-L98

https://github.com/emqx/CocoaMQTT/blob/1d53567bee10083c72a8f6155ccd837d686898cd/Source/CocoaMQTT.swift#L666

For this reason, the code has been modified so that ConnectReturnCode in 7-255 can also be initialized as reserved.

This is also a correct implementation according to the MQTT specification.

스크린샷 2022-12-14 오후 2 12 24

http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Table_3.1_-

leeway1208 commented 1 year ago

Thanks!