Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default MQTT Payload Parser can't handle empty messages #1975

Closed
fooker opened this issue Nov 20, 2019 · 4 comments · Fixed by #1976
Closed

Default MQTT Payload Parser can't handle empty messages #1975

fooker opened this issue Nov 20, 2019 · 4 comments · Fixed by #1976

Comments

@fooker
Copy link
Contributor

fooker commented Nov 20, 2019

MQTT supports sending messages without a payload (the remaining bytes after the variable headers are zero). If such a message is received by the MqttClient and processed by the default MqttPayloadParser, the client dies and does not accept any further messages.

At a first sight, it looks like malloc is called with message->publish.content.length which is 0 in such a case. Thus leading malloc to return nullptr and the following sanity-check to fail.

@slaff
Copy link
Contributor

slaff commented Nov 20, 2019

@fooker Can you send a PR with your suggested fix?

@fooker
Copy link
Contributor Author

fooker commented Nov 20, 2019

It looks like fixing the payloadParser is not enough. The on_data_payload and on_data_end callbacks will be called way to late (the are called if a follow-up message is received).

I've opened an associated issue in the according library: slaff/mqtt-codec#3

@fooker
Copy link
Contributor Author

fooker commented Nov 20, 2019

@slaff If slaff/mqtt-codec#4 gets merged, there is no need for change in Sming.

Another way to solve this is not to skip the callbacks on empty messages, but make them all be called with zero length. In such a case, I will come up with a PR.

@fooker
Copy link
Contributor Author

fooker commented Nov 20, 2019

@slaff will this be back-ported to a 4.0.x release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants