Skip to content

Commit

Permalink
[424]
Browse files Browse the repository at this point in the history
Fix mosquitto.db from becoming corrupted due to client messages being
persisted with no stored message.

Thanks to codami.

Bug: #424
  • Loading branch information
ralight committed Apr 13, 2017
1 parent 86001e9 commit a93a0c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
1.4.12 - 201703xx
=================

Broker:
- Fix mosquitto.db from becoming corrupted due to client messages being
persisted with no stored message. Closes #424.

1.4.11 - 20170220
=================

Expand Down
10 changes: 10 additions & 0 deletions src/persist.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ static int mqtt3_db_client_messages_write(struct mosquitto_db *db, FILE *db_fptr

cmsg = context->msgs;
while(cmsg){
if(!strncmp(cmsg->store->topic, "$SYS", 4)
&& cmsg->store->ref_count <= 1
&& cmsg->store->dest_id_count == 0){

/* This $SYS message won't have been persisted, so we can't persist
* this client message. */
cmsg = cmsg->next;
continue;
}

slen = strlen(context->id);

length = htonl(sizeof(dbid_t) + sizeof(uint16_t) + sizeof(uint8_t) +
Expand Down

0 comments on commit a93a0c9

Please sign in to comment.