Fix mosquitto.db from becoming corrupted due to client messages being
persisted with no stored message.

Thanks to codami.

Bug: https://github.com/eclipse/mosquitto/issues/424
This commit is contained in:
Roger A. Light
2017-04-13 13:40:12 +01:00
parent 86001e9059
commit a93a0c9bb1
2 changed files with 17 additions and 0 deletions
+7
View File
@@ -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
=================
+10
View File
@@ -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) +