zhaojh329 / libumqtt

A Lightweight and fully asynchronous MQTT client C library based on libev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

handle_publish 函数里的 > 是否应该是移位操作符?

zileyue163 opened this issue · comments

你好,
在文件 umqtt.c 的函数 static void handle_publish(struct umqtt_client *c1)中,
uint8_t qos = (pkt->flags > 1) & 0x03;
bool dup = (pkt->flags > 3) & 0x1;

是否应该是:
//huaguoqing fix, 2024.1.3 这里是移位,不是比较大小,此bug会造成当qos为2时,即0x4,被算成qos为1
//使用mosquitto 作为server,在客户端接收publish QOS为2的报文时,服务器报错并断连:disconnected due to protocol error.
uint8_t qos = (pkt->flags >> 1) & 0x03;
bool dup = (pkt->flags >> 3) & 0x1;