Long topics cause incorrect logging messages

Bug #785882 reported by Karl Palsson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mosquitto
Fix Released
Undecided
Unassigned

Bug Description

Section 2.2 of the MQTT spec says "The topic name is a UTF-encoded string. See the section on MQTT and UTF-8 for more information. Topic name has an upper length limit of 32,767 characters."

This is in keeping with all strings in mqtt being utf8, with two bytes for the length before hand.

However, posting to a topic as short as 6-700 bytes causes the topic to be garbled when received by the subscriber...

log from publisher....
C:\tools\mosquitto-0.10.1-win32-bin>mosquitto_pub -t "jjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj" -h localhost -m "zzz"

(701 bytes topic, plus 3 bytes payload)

C:\tools\mosquitto-0.10.1-win32-bin>

log from subscriber....
C:\tools\mosquitto-0.10.1-win32-bin>mosquitto_sub -h localhost -t "#" -d
Received CONNACK
Received SUBACK
Subscribed (mid: 1): 0
Received PUBLISH (d0, q0, r0, m0, 'jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjâ═;▲A'♣oP(ð
zzz
Sending PINGREQ
Received PINGRESP

(payload is correct, but topic is garbage after 465 bytes)

I've observed the same behaviour with my own client library. (I was testing that my library correctly published to a long topic)

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

I've not been able to reproduce this, but I've only got easy access to Linux right now. I'll try on Windows when I can. I tried various lengths including up to 30000 characters and they all seemed fine.

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

This is a bug in logging, not in the topic handling itself. Try running the subscriber as "mosquitto_sub -t # -v" to see what I mean.

Revision history for this message
Karl Palsson (ubuntu-tweak) wrote :

Do you want to duplicate this to: https://bugs.launchpad.net/mosquitto/+bug/785882 then? or do you want to keep that bug for tracking logging in mosquitto core broker?

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

I've renamed this bug to match the actual problem. I think it makes sense to keep it in this bug. Bug #778560 (which is the one I presume you meant) is more of a general sort out whereas this is a real bug.

summary: - long topics not supported, and cause corruption
+ Long topics cause incorrect logging messages
Changed in mosquitto:
milestone: none → 0.10.2
status: New → Fix Committed
Changed in mosquitto:
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.