Skip to content

Commit

Permalink
Fix calculation of remaining length parameter for websockets clients.
Browse files Browse the repository at this point in the history
Only affects those clients that send fragmented packets.

Closes #1974. Thanks to 贺亚东.
  • Loading branch information
ralight committed Jan 12, 2021
1 parent e78c04d commit 695bbc3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ChangeLog.txt
@@ -1,3 +1,11 @@
2.0.6 - 2021-01-xx
==================

Broker:
- Fix calculation of remaining length parameter for websockets clients that
send fragmented packets. Closes #1974.


2.0.5 - 2021-01-11
==================

Expand Down
2 changes: 1 addition & 1 deletion src/websockets.c
Expand Up @@ -332,7 +332,7 @@ static int callback_mqtt(
mosq->in_packet.remaining_length += (byte & 127) * mosq->in_packet.remaining_mult;
mosq->in_packet.remaining_mult *= 128;
}while((byte & 128) != 0);
mosq->in_packet.remaining_count = (int8_t)(mosq->in_packet.remaining_count -1);
mosq->in_packet.remaining_count = (int8_t)(mosq->in_packet.remaining_count * -1);

if(mosq->in_packet.remaining_length > 0){
mosq->in_packet.payload = mosquitto__malloc(mosq->in_packet.remaining_length*sizeof(uint8_t));
Expand Down

0 comments on commit 695bbc3

Please sign in to comment.