Skip to content

Commit

Permalink
Merge branch 'fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Jun 9, 2021
2 parents ff872cf + c4ca718 commit f68c052
Show file tree
Hide file tree
Showing 66 changed files with 690 additions and 297 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0042 NEW)

project(mosquitto)
set (VERSION 2.0.10)
set (VERSION 2.0.11)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")

Expand Down
27 changes: 27 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
2.0.11 - 2021-06-08
===================

Security:
- If a MQTT v5 client connects with a crafted CONNECT packet a memory leak
will occur. This has been fixed.

Broker:
- Fix possible crash having just upgraded from 1.6 if `per_listener_settings
true` is set, and a SIGHUP is sent to the broker before a client has
reconnected to the broker. Closes #2167.
- Fix bridge not reconnectng if the first reconnection attempt fails.
Closes #2207.
- Improve QoS 0 outgoing packet queueing.
- Fix non-reachable bridge blocking the broker on Windows. Closes #2172.
- Fix possible corruption of pollfd array on Windows when bridges were
reconnecting. Closes #2173.
- Fix QoS 0 messages not being queued when `queue_qos0_messages` was enabled.
Closes #2224.

Clients:
- If sending mosquitto_sub output to a pipe, mosquitto_sub will now detect
that the pipe has closed and disconnect. Closes #2164.
- Fix `mosquitto_pub -l` quitting if a message publication is attempted when
the broker is temporarily unavailable. Closes #2187.


2.0.10 - 2021-04-03
==================

Expand Down
2 changes: 2 additions & 0 deletions README-compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ are optional.
* libsystemd-dev (optional, if building with systemd support on Linux)
* On Windows, a pthreads library is required if threading support is to be
included.
* xsltproc (only if building from git)
* docbook-xsl (only if building from git)

To compile, run "make", but also see the file config.mk for more details on the
various options that can be compiled in.
Expand Down
6 changes: 3 additions & 3 deletions README-windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Capabilities
------------

Some versions of Windows have limitations on the number of concurrent
connections. In modern versions of Windows, e.g. Windows 10 or Windows Server
2019, this is approximately 8192 connections. In earlier versions of Windows,
this limit is 2048 connections.
connections due to the Windows API being used. In modern versions of Windows,
e.g. Windows 10 or Windows Server 2019, this is approximately 8192 connections.
In earlier versions of Windows, t his limit is 2048 connections.


Websockets
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ already be built. Use `make binary` to skip building the man pages, or install
### Build Dependencies

* c-ares (libc-ares-dev on Debian based systems) - only when compiled with `make WITH_SRV=yes`
* cJSON - for client JSON output support. Disable with `make WITH_CJSON=no` Auto detected with CMake.
* libwebsockets (libwebsockets-dev) - enable with `make WITH_WEBSOCKETS=yes`
* openssl (libssl-dev on Debian based systems) - disable with `make WITH_TLS=no`
* xsltproc (xsltproc and docbook-xsl on Debian based systems) - only needed when building from git sources - disable with `make WITH_DOCS=no`
* pthreads - for client library thread support. This is required to support the
`mosquitto_loop_start()` and `mosquitto_loop_stop()` functions. If compiled
without pthread support, the library isn't guaranteed to be thread safe.
* uthash / utlist - bundled versions of these headers are provided, disable their use with `make WITH_BUNDLED_DEPS=no`
* cJSON - for client JSON output support. Disable with `make WITH_CJSON=no` Auto detected with CMake.
* xsltproc (xsltproc and docbook-xsl on Debian based systems) - only needed when building from git sources - disable with `make WITH_DOCS=no`

Equivalent options for enabling/disabling features are available when using the CMake build.

Expand Down
3 changes: 1 addition & 2 deletions apps/db_dump/db_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ static void free__client_msg(struct P_client_msg *chunk)

static void free__msg_store(struct P_msg_store *chunk)
{
//free(chunk->source_id);
free(chunk->topic);
free(chunk->payload);
mosquitto_property_free_all(&chunk->properties);
Expand Down Expand Up @@ -425,7 +424,7 @@ int main(int argc, char *argv[])
read_e(fd, &header, 15);
if(!memcmp(header, magic, 15)){
if(do_print) printf("Mosquitto DB dump\n");
// Restore DB as normal
/* Restore DB as normal */
read_e(fd, &crc, sizeof(uint32_t));
if(do_print) printf("CRC: %d\n", crc);
read_e(fd, &i32temp, sizeof(uint32_t));
Expand Down
4 changes: 2 additions & 2 deletions apps/db_dump/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ void print__msg_store(struct P_msg_store *chunk, uint32_t length)
printf("DB_CHUNK_MSG_STORE:\n");
printf("\tLength: %d\n", length);
printf("\tStore ID: %" PRIu64 "\n", chunk->F.store_id);
//printf("\tSource ID: %s\n", chunk->source_id);
//printf("\tSource Username: %s\n", chunk->source_username);
/* printf("\tSource ID: %s\n", chunk->source_id); */
/* printf("\tSource Username: %s\n", chunk->source_username); */
printf("\tSource Port: %d\n", chunk->F.source_port);
printf("\tSource MID: %d\n", chunk->F.source_mid);
printf("\tTopic: %s\n", chunk->topic);
Expand Down
4 changes: 2 additions & 2 deletions apps/mosquitto_ctrl/dynsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ static void dynsec__payload_callback(struct mosq_ctrl *ctrl, long payloadlen, co
UNUSED(payloadlen);
tree = cJSON_Parse(payload);
#else
tree = cJSON_ParseWithLength(payload, payloadlen);
tree = cJSON_ParseWithLength(payload, (size_t)payloadlen);
#endif
if(tree == NULL){
fprintf(stderr, "Error: Payload not JSON.\n");
Expand Down Expand Up @@ -440,7 +440,7 @@ static void dynsec__payload_callback(struct mosq_ctrl *ctrl, long payloadlen, co
}else if(!strcasecmp(j_command->valuestring, "getAnonymousGroup")){
print_anonymous_group(j_response);
}else{
//fprintf(stderr, "%s: Success\n", j_command->valuestring);
/* fprintf(stderr, "%s: Success\n", j_command->valuestring); */
}
}
cJSON_Delete(tree);
Expand Down
2 changes: 1 addition & 1 deletion client/client_props.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int cfg_parse_property(struct mosq_config *cfg, int argc, char *argv[], int *idx
}

if(mosquitto_property_check_command(cmd, identifier)){
fprintf(stderr, "Error: %s property not allow for %s in --property argument.\n\n", propname, cmdname);
fprintf(stderr, "Error: %s property not allowed for %s in --property argument.\n\n", propname, cmdname);
return MOSQ_ERR_INVAL;
}

Expand Down
86 changes: 44 additions & 42 deletions client/client_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ static int check_format(const char *str)
for(i=0; i<len; i++){
if(str[i] == '%'){
if(i == len-1){
// error
/* error */
fprintf(stderr, "Error: Incomplete format specifier.\n");
return 1;
}else{
if(str[i+1] == '0' || str[i+1] == '-'){
/* Flag characters */
i++;
if(i == len-1){
// error
/* error */
fprintf(stderr, "Error: Incomplete format specifier.\n");
return 1;
}
Expand All @@ -71,7 +71,7 @@ static int check_format(const char *str)
while(str[i+1] >= '0' && str[i+1] <= '9'){
i++;
if(i == len-1){
// error
/* error */
fprintf(stderr, "Error: Incomplete format specifier.\n");
return 1;
}
Expand All @@ -81,65 +81,65 @@ static int check_format(const char *str)
/* Precision specifier */
i++;
if(i == len-1){
// error
/* error */
fprintf(stderr, "Error: Incomplete format specifier.\n");
return 1;
}
/* Precision */
while(str[i+1] >= '0' && str[i+1] <= '9'){
i++;
if(i == len-1){
// error
/* error */
fprintf(stderr, "Error: Incomplete format specifier.\n");
return 1;
}
}
}

if(str[i+1] == '%'){
// Print %, ignore
/* Print %, ignore */
}else if(str[i+1] == 'A'){
// MQTT v5 property topic-alias
/* MQTT v5 property topic-alias */
}else if(str[i+1] == 'C'){
// MQTT v5 property content-type
/* MQTT v5 property content-type */
}else if(str[i+1] == 'D'){
// MQTT v5 property correlation-data
/* MQTT v5 property correlation-data */
}else if(str[i+1] == 'E'){
// MQTT v5 property message-expiry-interval
/* MQTT v5 property message-expiry-interval */
}else if(str[i+1] == 'F'){
// MQTT v5 property payload-format-indicator
/* MQTT v5 property payload-format-indicator */
}else if(str[i+1] == 'I'){
// ISO 8601 date+time
/* ISO 8601 date+time */
}else if(str[i+1] == 'l'){
// payload length
/* payload length */
}else if(str[i+1] == 'm'){
// mid
/* mid */
}else if(str[i+1] == 'P'){
// MQTT v5 property user-property
/* MQTT v5 property user-property */
}else if(str[i+1] == 'p'){
// payload
/* payload */
}else if(str[i+1] == 'q'){
// qos
/* qos */
}else if(str[i+1] == 'R'){
// MQTT v5 property response-topic
/* MQTT v5 property response-topic */
}else if(str[i+1] == 'S'){
// MQTT v5 property subscription-identifier
/* MQTT v5 property subscription-identifier */
}else if(str[i+1] == 'r'){
// retain
/* retain */
}else if(str[i+1] == 't'){
// topic
/* topic */
}else if(str[i+1] == 'j'){
// JSON output, escaped payload
/* JSON output, escaped payload */
}else if(str[i+1] == 'J'){
// JSON output, assuming JSON payload
/* JSON output, assuming JSON payload */
}else if(str[i+1] == 'U'){
// Unix time+nanoseconds
/* Unix time+nanoseconds */
#ifdef WIN32
fprintf(stderr, "Error: The %%U format option is not supported on Windows.\n");
return 1;
#endif
}else if(str[i+1] == 'x' || str[i+1] == 'X'){
// payload in hex
/* payload in hex */
}else{
fprintf(stderr, "Error: Invalid format specifier '%c'.\n", str[i+1]);
return 1;
Expand All @@ -148,26 +148,26 @@ static int check_format(const char *str)
}
}else if(str[i] == '@'){
if(i == len-1){
// error
/* error */
fprintf(stderr, "Error: Incomplete format specifier.\n");
return 1;
}
i++;
}else if(str[i] == '\\'){
if(i == len-1){
// error
/* error */
fprintf(stderr, "Error: Incomplete escape specifier.\n");
return 1;
}else{
switch(str[i+1]){
case '\\': // '\'
case '0': // 0 (NULL)
case 'a': // alert
case 'e': // escape
case 'n': // new line
case 'r': // carriage return
case 't': // horizontal tab
case 'v': // vertical tab
case '\\': /* '\' */
case '0': /* 0 (NULL) */
case 'a': /* alert */
case 'e': /* escape */
case 'n': /* new line */
case 'r': /* carriage return */
case 't': /* horizontal tab */
case 'v': /* vertical tab */
break;

default:
Expand Down Expand Up @@ -756,8 +756,9 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c

tmp = strchr(url, '@');
if(tmp) {
char *colon;
*tmp++ = 0;
char *colon = strchr(url, ':');
colon = strchr(url, ':');
if(colon) {
*colon = 0;
cfg->password = strdup(colon + 1);
Expand Down Expand Up @@ -1462,12 +1463,13 @@ static int mosquitto__parse_socks_url(struct mosq_config *cfg, char *url)
return 1;
}

// socks5h:https://username:password@host:1883
// socks5h:https://username:password@host
// socks5h:https://username@host:1883
// socks5h:https://username@host
// socks5h:https://host:1883
// socks5h:https://host
/* socks5h:https://username:password@host:1883
* socks5h:https://username:password@host
* socks5h:https://username@host:1883
* socks5h:https://username@host
* socks5h:https://host:1883
* socks5h:https://host
*/

start = 0;
for(i=0; i<strlen(str); i++){
Expand Down
10 changes: 4 additions & 6 deletions client/pub_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flag
}else{
err_printf(&cfg, "Connection error: %s\n", mosquitto_connack_string(result));
}
// let the loop know that this is an unrecoverable connection
/* let the loop know that this is an unrecoverable connection */
status = STATUS_NOHOPE;
}
}
Expand Down Expand Up @@ -268,9 +268,8 @@ static int pub_stdin_line_loop(struct mosquitto *mosq)
line_buf[buf_len_actual-1] = '\0';
rc = my_publish(mosq, &mid_sent, cfg.topic, buf_len_actual-1, line_buf, cfg.qos, cfg.retain);
pos = 0;
if(rc){
err_printf(&cfg, "Error: Publish returned %d.\n", rc);
if(cfg.qos>0) return rc;
if(rc != MOSQ_ERR_SUCCESS && rc != MOSQ_ERR_NO_CONN){
return rc;
}
break;
}else{
Expand All @@ -288,7 +287,6 @@ static int pub_stdin_line_loop(struct mosquitto *mosq)
if(pos != 0){
rc = my_publish(mosq, &mid_sent, cfg.topic, buf_len_actual, line_buf, cfg.qos, cfg.retain);
if(rc){
err_printf(&cfg, "Error: Publish returned %d.\n", rc);
if(cfg.qos>0) return rc;
}
}
Expand Down Expand Up @@ -357,7 +355,7 @@ static int pub_other_loop(struct mosquitto *mosq)
rc = my_publish(mosq, &mid_sent, cfg.topic, 0, NULL, cfg.qos, cfg.retain);
break;
}
if(rc){
if(rc != MOSQ_ERR_SUCCESS && rc != MOSQ_ERR_NO_CONN){
err_printf(&cfg, "Error sending repeat publish: %s", mosquitto_strerror(rc));
}
}
Expand Down
3 changes: 3 additions & 0 deletions client/sub_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ static void my_message_callback(struct mosquitto *mosq, void *obj, const struct
}

print_message(&cfg, message, properties);
if(ferror(stdout)){
mosquitto_disconnect_v5(mosq, 0, cfg.disconnect_props);
}

if(cfg.msg_count>0){
msg_count++;
Expand Down
3 changes: 3 additions & 0 deletions client/sub_client_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ static int json_print(const struct mosquitto_message *message, const mosquitto_p
json_str = cJSON_PrintUnformatted(root);
}
cJSON_Delete(root);
if(json_str == NULL){
return MOSQ_ERR_NOMEM;
}

fputs(json_str, stdout);
free(json_str);
Expand Down
9 changes: 9 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
#if defined(_MSC_VER) && _MSC_VER < 1900
# define snprintf sprintf_s
# define EPROTO ECONNABORTED
# ifndef ECONNABORTED
# define ECONNABORTED WSAECONNABORTED
# endif
# ifndef ENOTCONN
# define ENOTCONN WSAENOTCONN
# endif
# ifndef ECONNREFUSED
# define ECONNREFUSED WSAECONNREFUSED
# endif
#endif

#ifdef WIN32
Expand Down
2 changes: 1 addition & 1 deletion config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ WITH_XTREPORT=no

# Also bump lib/mosquitto.h, CMakeLists.txt,
# installer/mosquitto.nsi, installer/mosquitto64.nsi
VERSION=2.0.10
VERSION=2.0.11

# Client library SO version. Bump if incompatible API/ABI changes are made.
SOVERSION=1
Expand Down
Loading

0 comments on commit f68c052

Please sign in to comment.