JustDoIt0910 / tinyMQTT

c实现的 MQTT 3.1.1 协议broker和client,支持 qos 0,1,2 消息、ACL 权限控制,支持 mongodb 消息存储。正在实现集群支持
MIT License
36 stars 11 forks source link

broker中存在一个段错误 #16

Open songxpu opened 9 months ago

songxpu commented 9 months ago

你好,在broker里发现一个问题,该输入可以触发broker崩溃。

echo 101b00044d5154540402003c000f746573745f345f375f335f3273756232080003313100000133| xxd -p -r | nc 127.0.0.1 1883

image

songxpu commented 9 months ago

valgrind提供的堆栈信息:

==17520== Thread 14:
==17520== Jump to the invalid address stated on the next line
==17520==    at 0x0: ???
==17520==    by 0x1242EB: parse_publish_packet (mqtt_proto_codec.c:204)
==17520==    by 0x124C55: decode_tcp_message_ (mqtt_proto_codec.c:435)
==17520==    by 0x11F16C: read_cb_ (mqtt_tcp_conn.c:30)
==17520==    by 0x11D0FC: tmq_event_loop_run (mqtt_event.c:102)
==17520==    by 0x127CF6: io_context_thread_func (mqtt_io_context.c:248)
==17520==    by 0x4874608: start_thread (pthread_create.c:477)
==17520==    by 0x51B1352: clone (clone.S:95)
==17520==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
JustDoIt0910 commented 9 months ago

感谢指出,我看一下

JustDoIt0910 commented 9 months ago

这个是因为客户端没有等待收到 CONNACK 连接成功消息就发送了 PUBLISH 消息导致的,虽然协议上是合法的,但是暂时还没有支持,是个需要优化的点