Problem with last will message containing 0x00 bytes

Bug #1035328 reported by Stefan Hudelmaier
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mosquitto
Fix Released
Undecided
Unassigned
mosquitto (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Hi,

we are using mqtt and mosquitto (0.15) to exchange binary (google protobuf) messages. Publishing and subcribing works great. When using last-will however, we have noticed that the subscribers of the last will message do not receive the full last will, but rather the bytes before the first 0x00 byte of the will payload. We suspect that it has something to do with using strlen in determining the payloadlen of the last will

read_handle_server.c:252
context->will->payloadlen = strlen(will_message);

If needed we can provide you with an example message.

Thank you for your great work on mosquitto!

Related branches

Revision history for this message
Stefan Hudelmaier (hudelmaier) wrote :

Sorry, just saw that it's specified in the MQTT standard that the last-will is an UTF-8 encoded string.

My bad.

Revision history for this message
Roger Light (roger.light) wrote :

Hi Stefan,

You're correct actually, this is a bug. There's a bit of confusion around the will payload in the spec. The will payload can be anything. The description "UTF-8 encoded string" here is really meant as "a two byte word describing the length of the payload, followed by that many bytes".

Thanks for the report, I'll see about getting it fixed shortly.

Changed in mosquitto:
milestone: none → 1.0
status: New → Confirmed
Revision history for this message
Roger Light (roger.light) wrote :

This has now been fixed: https://bitbucket.org/oojah/mosquitto/changeset/2272f88cf9e117b0b44ce819f22cc14191ab6f90

It'd be great if you could confirm that it works for you (use https://bitbucket.org/oojah/mosquitto/get/0.16.bz2 ).

Thanks again.

Changed in mosquitto:
status: Confirmed → Fix Committed
Revision history for this message
Stefan Hudelmaier (hudelmaier) wrote :

Hi Roger,

wow, that was fast :) We will test this with our protobuf will on monday.

Stefan

Revision history for this message
Stefan Hudelmaier (hudelmaier) wrote :

Roger,

we can confirm that your fix works for our will message.

Many thanks,
Stefan

Changed in mosquitto:
status: Fix Committed → Fix Released
Revision history for this message
Roger Light (roger.light) wrote :

This was fixed a long time ago in mosquitto, the upload to vivid of mosquitto-1.3.4 closes the bug.

Changed in mosquitto (Ubuntu):
status: New → Fix Committed
Changed in mosquitto (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.