diff --git a/ChangeLog.txt b/ChangeLog.txt index 73b29b75ea..ffc5f40e58 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -4,6 +4,7 @@ Broker: - Fix `tls_version` behaviour not matching documentation. It was setting the exact TLS version to use, not the minimium TLS version to use. Closes #2110. +- Fix messages to `$` prefixed topics being rejected. Closes #2111. 2.0.8 - 2021-02-25 diff --git a/src/retain.c b/src/retain.c index ca9e73134b..ee8ad60959 100644 --- a/src/retain.c +++ b/src/retain.c @@ -83,7 +83,10 @@ int retain__store(const char *topic, struct mosquitto_msg_store *stored, char ** assert(split_topics); HASH_FIND(hh, db.retains, split_topics[0], strlen(split_topics[0]), retainhier); - if(retainhier == NULL) return MOSQ_ERR_NOT_FOUND; + if(retainhier == NULL){ + retainhier = retain__add_hier_entry(NULL, &db.retains, split_topics[0], (uint16_t)strlen(split_topics[0])); + if(!retainhier) return MOSQ_ERR_NOMEM; + } for(i=0; split_topics[i] != NULL; i++){ slen = strlen(split_topics[i]);