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

Segmented writes do not work if len(topic) > TX buffer size #105

Closed
denravonska opened this issue Apr 5, 2019 · 0 comments · Fixed by #137
Closed

Segmented writes do not work if len(topic) > TX buffer size #105

denravonska opened this issue Apr 5, 2019 · 0 comments · Fixed by #137
Assignees

Comments

@denravonska
Copy link

denravonska commented Apr 5, 2019

I don't know if this is by design, but "segmented" writes (fill buffer -> write -> fill buffer -> write) does not work if the header and topic length exceeds the TX buffer size when writing. In this crash I tried a TX buffer size of 16 when publishing to abcde/Sally-2.local/status:

frame #1: 0x00000001000a48d7 test `MqttEncode_Publish(tx_buf="����\x7f", tx_buf_len=16, publish=0x00007ffeefbfee28, use_cb='\0') at mqtt_packet.c:842
   839 	        if (payload_len > (tx_buf_len - (header_len + variable_len))) {
   840 	            payload_len = (tx_buf_len - (header_len + variable_len));
   841 	        }
-> 842 	        XMEMCPY(tx_payload, publish->buffer, payload_len);
   843 	    }
   844 	    publish->intBuf_pos = 0;
   845 	    publish->intBuf_len = payload_len;
(lldb) print payload_len
(int) $0 = -16
(lldb) print header_len
(int) $1 = 2
(lldb) print variable_len
(int) $2 = 30
(lldb) print tx_buf_len
(int) $3 = 16

If I increase the buffer size to 32 it works as expected.

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.

3 participants