Fixes for the poor souls stuck on <c99.

Closes #1622.
This commit is contained in:
Roger A. Light 2020-03-12 10:29:11 +00:00
parent c175e836a7
commit c84d175b3d
16 changed files with 145 additions and 119 deletions

View File

@ -1,3 +1,7 @@
Build:
- Various fixes for building with <C99 support. Closes #1622.
1.6.9 - 20200227
================

View File

@ -47,12 +47,13 @@ void memory__set_limit(size_t lim)
void *mosquitto__calloc(size_t nmemb, size_t size)
{
void *mem;
#ifdef REAL_WITH_MEMORY_TRACKING
if(mem_limit && memcount + size > mem_limit){
return NULL;
}
#endif
void *mem = calloc(nmemb, size);
mem = calloc(nmemb, size);
#ifdef REAL_WITH_MEMORY_TRACKING
if(mem){
@ -79,12 +80,15 @@ void mosquitto__free(void *mem)
void *mosquitto__malloc(size_t size)
{
void *mem;
#ifdef REAL_WITH_MEMORY_TRACKING
if(mem_limit && memcount + size > mem_limit){
return NULL;
}
#endif
void *mem = malloc(size);
mem = malloc(size);
#ifdef REAL_WITH_MEMORY_TRACKING
if(mem){
@ -112,13 +116,11 @@ unsigned long mosquitto__max_memory_used(void)
void *mosquitto__realloc(void *ptr, size_t size)
{
void *mem;
#ifdef REAL_WITH_MEMORY_TRACKING
if(mem_limit && memcount + size > mem_limit){
return NULL;
}
#endif
void *mem;
#ifdef REAL_WITH_MEMORY_TRACKING
if(ptr){
memcount -= malloc_usable_size(ptr);
}
@ -139,12 +141,13 @@ void *mosquitto__realloc(void *ptr, size_t size)
char *mosquitto__strdup(const char *s)
{
char *str;
#ifdef REAL_WITH_MEMORY_TRACKING
if(mem_limit && memcount + strlen(s) > mem_limit){
return NULL;
}
#endif
char *str = strdup(s);
str = strdup(s);
#ifdef REAL_WITH_MEMORY_TRACKING
if(str){
@ -157,4 +160,3 @@ char *mosquitto__strdup(const char *s)
return str;
}

View File

@ -165,7 +165,6 @@ struct mosquitto_message_all{
struct mosquitto_message_all *prev;
mosquitto_property *properties;
time_t timestamp;
//enum mosquitto_msg_direction direction;
enum mosquitto_msg_state state;
bool dup;
struct mosquitto_message msg;
@ -321,7 +320,7 @@ struct mosquitto {
void (*on_unsubscribe)(struct mosquitto *, void *userdata, int mid);
void (*on_unsubscribe_v5)(struct mosquitto *, void *userdata, int mid, const mosquitto_property *props);
void (*on_log)(struct mosquitto *, void *userdata, int level, const char *str);
//void (*on_error)();
/*void (*on_error)();*/
char *host;
int port;
char *bind_address;

View File

@ -482,11 +482,11 @@ void net__print_ssl_error(struct mosquitto *mosq)
int net__socket_connect_tls(struct mosquitto *mosq)
{
int ret, err;
long res;
ERR_clear_error();
long res;
if (mosq->tls_ocsp_required) {
// Note: OCSP is available in all currently supported OpenSSL versions.
/* Note: OCSP is available in all currently supported OpenSSL versions. */
if ((res=SSL_set_tlsext_status_type(mosq->ssl, TLSEXT_STATUSTYPE_ocsp)) != 1) {
log__printf(mosq, MOSQ_LOG_ERR, "Could not activate OCSP (error: %ld)", res);
return MOSQ_ERR_OCSP;
@ -537,6 +537,9 @@ static int net__init_ssl_ctx(struct mosquitto *mosq)
ENGINE *engine = NULL;
uint8_t tls_alpn_wire[256];
uint8_t tls_alpn_len;
#if !defined(OPENSSL_NO_ENGINE)
EVP_PKEY *pkey;
#endif
if(mosq->ssl_ctx){
if(!mosq->ssl_ctx_defaults){
@ -595,7 +598,7 @@ static int net__init_ssl_ctx(struct mosquitto *mosq)
/* Set ALPN */
if(mosq->tls_alpn) {
tls_alpn_len = (uint8_t) strnlen(mosq->tls_alpn, 254);
tls_alpn_wire[0] = tls_alpn_len; // first byte is length of string
tls_alpn_wire[0] = tls_alpn_len; /* first byte is length of string */
memcpy(tls_alpn_wire + 1, mosq->tls_alpn, tls_alpn_len);
SSL_CTX_set_alpn_protos(mosq->ssl_ctx, tls_alpn_wire, tls_alpn_len + 1);
}
@ -718,7 +721,7 @@ static int net__init_ssl_ctx(struct mosquitto *mosq)
}
ui_method = NULL;
}
EVP_PKEY *pkey = ENGINE_load_private_key(engine, mosq->tls_keyfile, ui_method, NULL);
pkey = ENGINE_load_private_key(engine, mosq->tls_keyfile, ui_method, NULL);
if(!pkey){
log__printf(mosq, MOSQ_LOG_ERR, "Error: Unable to load engine private key file \"%s\".", mosq->tls_keyfile);
ENGINE_FINISH(engine);

View File

@ -64,7 +64,7 @@ int mosquitto__verify_ocsp_status_cb(SSL * ssl, void *arg)
long len = SSL_get_tlsext_status_ocsp_resp(mosq->ssl, &p);
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: SSL_get_tlsext_status_ocsp_resp returned %ld bytes", len);
// the following functions expect a const pointer
/* the following functions expect a const pointer */
cp = (const unsigned char *)p;
if (!cp || len <= 0) {
@ -100,9 +100,10 @@ int mosquitto__verify_ocsp_status_cb(SSL * ssl, void *arg)
st = SSL_CTX_get_cert_store(mosq->ssl_ctx);
// Note:
// Other checkers often fix problems in OpenSSL before 1.0.2a (e.g. libcurl).
// For all currently supported versions of the OpenSSL project, this is not needed anymore.
/* Note:
* Other checkers often fix problems in OpenSSL before 1.0.2a (e.g. libcurl).
* For all currently supported versions of the OpenSSL project, this is not needed anymore.
*/
if ((result2=OCSP_basic_verify(br, ch, st, 0)) <= 0) {
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: response verification failed (error: %d)", result2);
@ -126,7 +127,7 @@ int mosquitto__verify_ocsp_status_cb(SSL * ssl, void *arg)
switch(cert_status) {
case V_OCSP_CERTSTATUS_GOOD:
// Note: A OCSP stapling result will be accepted up to 5 minutes after it expired!
/* Note: A OCSP stapling result will be accepted up to 5 minutes after it expired! */
if(!OCSP_check_validity(thisupd, nextupd, 300L, -1L)) {
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: OCSP response has expired");
goto end;
@ -149,11 +150,11 @@ int mosquitto__verify_ocsp_status_cb(SSL * ssl, void *arg)
if (br!=NULL) OCSP_BASICRESP_free(br);
if (rsp!=NULL) OCSP_RESPONSE_free(rsp);
return 1; // OK
return 1; /* OK */
end:
if (br!=NULL) OCSP_BASICRESP_free(br);
if (rsp!=NULL) OCSP_RESPONSE_free(rsp);
return 0; // Not OK
return 0; /* Not OK */
}
#endif

View File

@ -45,11 +45,11 @@ int mosquitto_validate_utf8(const char *str, int len)
codelen = 2;
codepoint = (ustr[i] & 0x1F);
}else if((ustr[i] & 0xF0) == 0xE0){
// 1110xxxx - 3 byte sequence
/* 1110xxxx - 3 byte sequence */
codelen = 3;
codepoint = (ustr[i] & 0x0F);
}else if((ustr[i] & 0xF8) == 0xF0){
// 11110xxx - 4 byte sequence
/* 11110xxx - 4 byte sequence */
if(ustr[i] > 0xF4){
/* Invalid, this would produce values > 0x10FFFF. */
return MOSQ_ERR_MALFORMED_UTF8;

View File

@ -778,6 +778,10 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
struct mosquitto__listener *cur_listener = &config->default_listener;
int i;
int lineno_ext = 0;
char **files;
int file_count;
char *kpass_sha = NULL, *kpass_sha_bin = NULL;
char *keyform ;
*lineno = 0;
@ -798,7 +802,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
if(conf__parse_string(&token, "acl_file", &cur_security_options->acl_file, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "address") || !strcmp(token, "addresses")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge || cur_bridge->addresses){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -860,7 +864,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
conf__set_cur_security_options(config, cur_listener, &cur_security_options);
if(conf__parse_bool(&token, "allow_zero_length_clientid", &cur_security_options->allow_zero_length_clientid, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strncmp(token, "auth_opt_", 9)){
if(reload) continue; // Auth plugin not currently valid for reloading.
if(reload) continue; /* Auth plugin not currently valid for reloading. */
if(!cur_auth_plugin_config){
log__printf(NULL, MOSQ_LOG_ERR, "Error: An auth_opt_ option exists in the config file without an auth_plugin.");
return MOSQ_ERR_INVAL;
@ -903,7 +907,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
return MOSQ_ERR_INVAL;
}
}else if(!strcmp(token, "auth_plugin")){
if(reload) continue; // Auth plugin not currently valid for reloading.
if(reload) continue; /* Auth plugin not currently valid for reloading. */
conf__set_cur_security_options(config, cur_listener, &cur_security_options);
cur_security_options->auth_plugin_configs = mosquitto__realloc(cur_security_options->auth_plugin_configs, (cur_security_options->auth_plugin_config_count+1)*sizeof(struct mosquitto__auth_plugin_config));
if(!cur_security_options->auth_plugin_configs){
@ -919,7 +923,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
cur_security_options->auth_plugin_config_count++;
if(conf__parse_string(&token, "auth_plugin", &cur_auth_plugin_config->path, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "auth_plugin_deny_special_chars")){
if(reload) continue; // Auth plugin not currently valid for reloading.
if(reload) continue; /* Auth plugin not currently valid for reloading. */
if(!cur_auth_plugin_config){
log__printf(NULL, MOSQ_LOG_ERR, "Error: An auth_plugin_deny_special_chars option exists in the config file without an auth_plugin.");
return MOSQ_ERR_INVAL;
@ -939,14 +943,14 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
}else if(!strcmp(token, "autosave_on_changes")){
if(conf__parse_bool(&token, "autosave_on_changes", &config->autosave_on_changes, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "bind_address")){
if(reload) continue; // Listener not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_string(&token, "default listener bind_address", &config->default_listener.host, saveptr)) return MOSQ_ERR_INVAL;
if(conf__attempt_resolve(config->default_listener.host, "bind_address", MOSQ_LOG_ERR, "Error")){
return MOSQ_ERR_INVAL;
}
}else if(!strcmp(token, "bind_interface")){
#ifdef SO_BINDTODEVICE
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_string(&token, "bind_interface", &cur_listener->bind_interface, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_ERR, "Error: bind_interface specified but socket option not available.");
@ -954,7 +958,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "bridge_attempt_unsubscribe")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -965,7 +969,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "bridge_cafile")){
#if defined(WITH_BRIDGE) && defined(WITH_TLS)
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -982,7 +986,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "bridge_alpn")){
#if defined(WITH_BRIDGE) && defined(WITH_TLS)
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -993,7 +997,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "bridge_capath")){
#if defined(WITH_BRIDGE) && defined(WITH_TLS)
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1010,7 +1014,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "bridge_certfile")){
#if defined(WITH_BRIDGE) && defined(WITH_TLS)
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1027,7 +1031,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "bridge_identity")){
#if defined(WITH_BRIDGE) && defined(FINAL_WITH_TLS_PSK)
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1042,7 +1046,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "bridge_insecure")){
#if defined(WITH_BRIDGE) && defined(WITH_TLS)
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1056,7 +1060,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "bridge_require_ocsp")){
#if defined(WITH_BRIDGE) && defined(WITH_TLS)
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1067,7 +1071,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "bridge_keyfile")){
#if defined(WITH_BRIDGE) && defined(WITH_TLS)
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1084,7 +1088,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "bridge_protocol_version")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1108,7 +1112,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "bridge_psk")){
#if defined(WITH_BRIDGE) && defined(FINAL_WITH_TLS_PSK)
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1123,7 +1127,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "bridge_tls_version")){
#if defined(WITH_BRIDGE) && defined(WITH_TLS)
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1134,7 +1138,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "cafile")){
#if defined(WITH_TLS)
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(cur_listener->psk_hint){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Cannot use both certificate and psk encryption in a single listener.");
return MOSQ_ERR_INVAL;
@ -1145,14 +1149,14 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "capath")){
#ifdef WITH_TLS
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_string(&token, "capath", &cur_listener->capath, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
#endif
}else if(!strcmp(token, "certfile")){
#ifdef WITH_TLS
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(cur_listener->psk_hint){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Cannot use both certificate and psk encryption in a single listener.");
return MOSQ_ERR_INVAL;
@ -1166,14 +1170,14 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
if(conf__parse_bool(&token, "check_retain_source", &config->check_retain_source, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "ciphers")){
#ifdef WITH_TLS
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_string(&token, "ciphers", &cur_listener->ciphers, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
#endif
}else if(!strcmp(token, "clientid") || !strcmp(token, "remote_clientid")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1184,7 +1188,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "cleansession")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1201,7 +1205,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
if(conf__parse_string(&token, "clientid_prefixes", &config->clientid_prefixes, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "connection")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
token = strtok_r(NULL, " ", &saveptr);
if(token){
/* Check for existing bridge name. */
@ -1249,28 +1253,28 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
if(conf__parse_bool(&token, token, &config->connection_messages, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "crlfile")){
#ifdef WITH_TLS
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_string(&token, "crlfile", &cur_listener->crlfile, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
#endif
}else if(!strcmp(token, "dhparamfile")){
#ifdef WITH_TLS
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_string(&token, "dhparamfile", &cur_listener->dhparamfile, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
#endif
}else if(!strcmp(token, "http_dir")){
#ifdef WITH_WEBSOCKETS
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_string(&token, "http_dir", &cur_listener->http_dir, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Websockets support not available.");
#endif
}else if(!strcmp(token, "idle_timeout")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1292,8 +1296,6 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
return 1;
}
char **files;
int file_count;
rc = config__get_dir_files(token, &files, &file_count);
if(rc) return rc;
@ -1317,7 +1319,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
}
}else if(!strcmp(token, "keepalive_interval")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1332,7 +1334,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "keyfile")){
#ifdef WITH_TLS
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_string(&token, "keyfile", &cur_listener->keyfile, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
@ -1392,7 +1394,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
}
}else if(!strcmp(token, "local_clientid")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1403,7 +1405,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "local_password")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1414,7 +1416,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "local_username")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1549,7 +1551,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty log_type value in configuration.");
}
}else if(!strcmp(token, "max_connections")){
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
token = strtok_r(NULL, " ", &saveptr);
if(token){
cur_listener->max_connections = atoi(token);
@ -1558,7 +1560,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty max_connections value in configuration.");
}
}else if(!strcmp(token, "maximum_qos")){
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_int(&token, "maximum_qos", &tmp_int, saveptr)) return MOSQ_ERR_INVAL;
if(tmp_int < 0 || tmp_int > 2){
log__printf(NULL, MOSQ_LOG_ERR, "Error: maximum_qos must be between 0 and 2 inclusive.");
@ -1625,7 +1627,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
return MOSQ_ERR_INVAL;
}
}else if(!strcmp(token, "mount_point")){
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(config->listener_count == 0){
log__printf(NULL, MOSQ_LOG_ERR, "Error: You must use create a listener before using the mount_point option in the configuration file.");
return MOSQ_ERR_INVAL;
@ -1639,7 +1641,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
}
}else if(!strcmp(token, "notifications")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1650,7 +1652,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "notifications_local_only")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration");
return MOSQ_ERR_INVAL;
@ -1661,7 +1663,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "notification_topic")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1672,7 +1674,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "password") || !strcmp(token, "remote_password")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1733,10 +1735,10 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty persistent_client_expiration value in configuration.");
}
}else if(!strcmp(token, "pid_file")){
if(reload) continue; // pid file not valid for reloading.
if(reload) continue; /* pid file not valid for reloading. */
if(conf__parse_string(&token, "pid_file", &config->pid_file, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "port")){
if(reload) continue; // Listener not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(config->default_listener.port){
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Default listener port specified multiple times. Only the latest will be used.");
}
@ -1783,7 +1785,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "psk_hint")){
#ifdef FINAL_WITH_TLS_PSK
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_string(&token, "psk_hint", &cur_listener->psk_hint, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS/TLS-PSK support not available.");
@ -1792,14 +1794,14 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
if(conf__parse_bool(&token, token, &config->queue_qos0_messages, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "require_certificate")){
#ifdef WITH_TLS
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_bool(&token, "require_certificate", &cur_listener->require_certificate, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
#endif
}else if(!strcmp(token, "restart_timeout")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1832,7 +1834,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: The retry_interval option is no longer available.");
}else if(!strcmp(token, "round_robin")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1845,7 +1847,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
if(conf__parse_bool(&token, "set_tcp_nodelay", &config->set_tcp_nodelay, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "start_type")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1873,7 +1875,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
#endif
}else if(!strcmp(token, "socket_domain")){
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
token = strtok_r(NULL, " ", &saveptr);
if(token){
if(!strcmp(token, "ipv4")){
@ -1898,7 +1900,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
}
}else if(!strcmp(token, "threshold")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -1913,15 +1915,14 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "tls_engine")){
#ifdef WITH_TLS
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_string(&token, "tls_engine", &cur_listener->tls_engine, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
#endif
}else if(!strcmp(token, "tls_engine_kpass_sha1")){
#ifdef WITH_TLS
if(reload) continue; // Listeners not valid for reloading.
char *kpass_sha = NULL, *kpass_sha_bin = NULL;
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_string(&token, "tls_engine_kpass_sha1", &kpass_sha, saveptr)) return MOSQ_ERR_INVAL;
if(mosquitto__hex2bin_sha1(kpass_sha, (unsigned char**)&kpass_sha_bin) != MOSQ_ERR_SUCCESS){
mosquitto__free(kpass_sha);
@ -1934,8 +1935,8 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "tls_keyform")){
#ifdef WITH_TLS
if(reload) continue; // Listeners not valid for reloading.
char *keyform = NULL;
if(reload) continue; /* Listeners not valid for reloading. */
keyform = NULL;
if(conf__parse_string(&token, "tls_keyform", &keyform, saveptr)) return MOSQ_ERR_INVAL;
cur_listener->tls_keyform = mosq_k_pem;
if(!strcmp(keyform, "engine")) cur_listener->tls_keyform = mosq_k_engine;
@ -1945,14 +1946,14 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
#endif
}else if(!strcmp(token, "tls_version")){
#if defined(WITH_TLS)
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_string(&token, "tls_version", &cur_listener->tls_version, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
#endif
}else if(!strcmp(token, "topic")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -2105,7 +2106,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
#endif
}else if(!strcmp(token, "max_topic_alias")){
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
token = strtok_r(NULL, " ", &saveptr);
if(token){
cur_listener->max_topic_alias = atoi(token);
@ -2114,7 +2115,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
}
}else if(!strcmp(token, "try_private")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;
@ -2127,28 +2128,28 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
if(conf__parse_bool(&token, token, &config->upgrade_outgoing_qos, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "use_identity_as_username")){
#ifdef WITH_TLS
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_bool(&token, "use_identity_as_username", &cur_listener->use_identity_as_username, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
#endif
}else if(!strcmp(token, "use_subject_as_username")){
#ifdef WITH_TLS
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_bool(&token, "use_subject_as_username", &cur_listener->use_subject_as_username, saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
#endif
}else if(!strcmp(token, "user")){
if(reload) continue; // Drop privileges user not valid for reloading.
if(reload) continue; /* Drop privileges user not valid for reloading. */
mosquitto__free(config->user);
if(conf__parse_string(&token, "user", &config->user, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "use_username_as_clientid")){
if(reload) continue; // Listeners not valid for reloading.
if(reload) continue; /* Listeners not valid for reloading. */
if(conf__parse_bool(&token, "use_username_as_clientid", &cur_listener->use_username_as_clientid, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "username") || !strcmp(token, "remote_username")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(reload) continue; /* FIXME */
if(!cur_bridge){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
return MOSQ_ERR_INVAL;

View File

@ -74,6 +74,8 @@ static bool db__ready_for_queue(struct mosquitto *context, int qos, struct mosqu
int adjust_count;
unsigned long source_bytes;
unsigned long adjust_bytes = max_inflight_bytes;
bool valid_bytes;
bool valid_count;
if(max_queued == 0 && max_queued_bytes == 0){
return true;
@ -94,8 +96,8 @@ static bool db__ready_for_queue(struct mosquitto *context, int qos, struct mosqu
adjust_count = 0;
}
bool valid_bytes = source_bytes - adjust_bytes < max_queued_bytes;
bool valid_count = source_count - adjust_count < max_queued;
valid_bytes = source_bytes - adjust_bytes < max_queued_bytes;
valid_count = source_count - adjust_count < max_queued;
if(max_queued_bytes == 0){
return valid_count;
@ -124,7 +126,7 @@ int db__open(struct mosquitto__config *config, struct mosquitto_db *db)
db->bridge_count = 0;
#endif
// Initialize the hashtable
/* Initialize the hashtable */
db->clientid_index_hash = NULL;
db->subs = NULL;

View File

@ -378,12 +378,17 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context)
uint16_t auth_data_len = 0;
void *auth_data_out = NULL;
uint16_t auth_data_out_len = 0;
bool allow_zero_length_clientid;
#ifdef WITH_TLS
int i;
X509 *client_cert = NULL;
X509_NAME *name;
X509_NAME_ENTRY *name_entry;
ASN1_STRING *name_asn1 = NULL;
BIO *subject_bio;
char *data_start;
long name_length;
char *subject;
#endif
G_CONNECTION_COUNT_INC();
@ -494,7 +499,7 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context)
rc = MOSQ_ERR_PROTOCOL;
goto handle_connect_error;
}
will_retain = ((connect_flags & 0x20) == 0x20); // Temporary hack because MSVC<1800 doesn't have stdbool.h.
will_retain = ((connect_flags & 0x20) == 0x20);
password_flag = connect_flags & 0x40;
username_flag = connect_flags & 0x80;
@ -537,7 +542,6 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context)
mosquitto__free(client_id);
client_id = NULL;
bool allow_zero_length_clientid;
if(db->config->per_listener_settings){
allow_zero_length_clientid = context->listener->security_options.allow_zero_length_clientid;
}else{
@ -687,7 +691,7 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context)
rc = 1;
goto handle_connect_error;
}
if (context->listener->use_identity_as_username) { //use_identity_as_username
if (context->listener->use_identity_as_username) { /* use_identity_as_username */
i = X509_NAME_get_index_by_NID(name, NID_commonName, -1);
if(i == -1){
if(context->protocol == mosq_p_mqtt5){
@ -735,12 +739,12 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context)
goto handle_connect_error;
}
}
} else { // use_subject_as_username
BIO *subject_bio = BIO_new(BIO_s_mem());
} else { /* use_subject_as_username */
subject_bio = BIO_new(BIO_s_mem());
X509_NAME_print_ex(subject_bio, X509_get_subject_name(client_cert), 0, XN_FLAG_RFC2253);
char *data_start = NULL;
long name_length = BIO_get_mem_data(subject_bio, &data_start);
char *subject = mosquitto__malloc(sizeof(char)*name_length+1);
data_start = NULL;
name_length = BIO_get_mem_data(subject_bio, &data_start);
subject = mosquitto__malloc(sizeof(char)*name_length+1);
if(!subject){
BIO_free(subject_bio);
rc = MOSQ_ERR_NOMEM;

View File

@ -444,6 +444,10 @@ int net__tls_load_verify(struct mosquitto__listener *listener)
{
#ifdef WITH_TLS
ENGINE *engine = NULL;
# if !defined(OPENSSL_NO_ENGINE)
UI_METHOD *ui_method;
EVP_PKEY *pkey;
# endif
int rc;
rc = SSL_CTX_load_verify_locations(listener->ssl_ctx, listener->cafile, listener->capath);
@ -493,7 +497,7 @@ int net__tls_load_verify(struct mosquitto__listener *listener)
}
if(listener->tls_engine && listener->tls_keyform == mosq_k_engine){
#if !defined(OPENSSL_NO_ENGINE)
UI_METHOD *ui_method = net__get_ui_method();
ui_method = net__get_ui_method();
if(listener->tls_engine_kpass_sha1){
if(!ENGINE_ctrl_cmd(engine, ENGINE_SECRET_MODE, ENGINE_SECRET_MODE_SHA, NULL, NULL, 0)){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Unable to set engine secret mode sha");
@ -509,7 +513,7 @@ int net__tls_load_verify(struct mosquitto__listener *listener)
}
ui_method = NULL;
}
EVP_PKEY *pkey = ENGINE_load_private_key(engine, listener->keyfile, ui_method, NULL);
pkey = ENGINE_load_private_key(engine, listener->keyfile, ui_method, NULL);
if(!pkey){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Unable to load engine private key file \"%s\".", listener->keyfile);
net__print_ssl_error(NULL);

View File

@ -408,7 +408,7 @@ int persist__restore(struct mosquitto_db *db)
goto error;
}
if(!memcmp(header, magic, 15)){
// Restore DB as normal
/* Restore DB as normal */
read_e(fptr, &crc, sizeof(uint32_t));
read_e(fptr, &i32temp, sizeof(uint32_t));
db_version = ntohl(i32temp);

View File

@ -57,8 +57,8 @@ int persist__chunk_header_read_v234(FILE *db_fptr, int *chunk, int *length)
int persist__chunk_cfg_read_v234(FILE *db_fptr, struct PF_cfg *chunk)
{
read_e(db_fptr, &chunk->shutdown, sizeof(uint8_t)); // shutdown
read_e(db_fptr, &chunk->dbid_size, sizeof(uint8_t)); // sizeof(dbid_t)
read_e(db_fptr, &chunk->shutdown, sizeof(uint8_t)); /* shutdown */
read_e(db_fptr, &chunk->dbid_size, sizeof(uint8_t)); /* sizeof(dbid_t) */
read_e(db_fptr, &chunk->last_db_id, sizeof(dbid_t));
return MOSQ_ERR_SUCCESS;

View File

@ -549,7 +549,7 @@ int mosquitto_security_cleanup(struct mosquitto_db *db, bool reload)
}
//int mosquitto_acl_check(struct mosquitto_db *db, struct mosquitto *context, const char *topic, int access)
/* int mosquitto_acl_check(struct mosquitto_db *db, struct mosquitto *context, const char *topic, int access) */
static int acl__check_single(struct mosquitto__auth_plugin_config *auth_plugin, struct mosquitto *context, struct mosquitto_acl_msg *msg, int access)
{
const char *username;
@ -610,7 +610,7 @@ static int acl__check_dollar(const char *topic, int access)
}else if(!strncmp(topic, "$share", 6)){
/* Only allow sub/unsub to shared subscriptions */
if(access == MOSQ_ACL_SUBSCRIBE){
//FIXME if(access == MOSQ_ACL_SUBSCRIBE || access == MOSQ_ACL_UNSUBSCRIBE){
/* FIXME if(access == MOSQ_ACL_SUBSCRIBE || access == MOSQ_ACL_UNSUBSCRIBE){ */
return MOSQ_ERR_SUCCESS;
}else{
return MOSQ_ERR_ACL_DENIED;

View File

@ -396,7 +396,7 @@ int mosquitto_acl_check_default(struct mosquitto_db *db, struct mosquitto *conte
len = tlen + acl_root->ccount*(clen-2);
}
local_acl = mosquitto__malloc(len+1);
if(!local_acl) return 1; // FIXME
if(!local_acl) return 1; /* FIXME */
s = local_acl;
for(i=0; i<tlen; i++){
if(i<tlen-1 && acl_root->topic[i] == '%'){
@ -465,8 +465,9 @@ static int aclfile__parse(struct mosquitto_db *db, struct mosquitto__security_op
return 1;
}
// topic [read|write] <topic>
// user <user>
/* topic [read|write] <topic>
* user <user>
*/
while(fgets_extending(&buf, &buflen, aclfptr)){
slen = strlen(buf);
@ -1000,6 +1001,10 @@ int mosquitto_security_apply_default(struct mosquitto_db *db)
X509_NAME_ENTRY *name_entry;
ASN1_STRING *name_asn1 = NULL;
struct mosquitto__listener *listener;
BIO *subject_bio;
char *data_start;
long name_length;
char *subject;
#endif
if(!db) return MOSQ_ERR_INVAL;
@ -1078,7 +1083,7 @@ int mosquitto_security_apply_default(struct mosquitto_db *db)
security__disconnect_auth(db, context);
continue;
}
if (context->listener->use_identity_as_username) { //use_identity_as_username
if (context->listener->use_identity_as_username) { /* use_identity_as_username */
i = X509_NAME_get_index_by_NID(name, NID_commonName, -1);
if(i == -1){
X509_free(client_cert);
@ -1114,12 +1119,12 @@ int mosquitto_security_apply_default(struct mosquitto_db *db)
continue;
}
}
} else { // use_subject_as_username
BIO *subject_bio = BIO_new(BIO_s_mem());
} else { /* use_subject_as_username */
subject_bio = BIO_new(BIO_s_mem());
X509_NAME_print_ex(subject_bio, X509_get_subject_name(client_cert), 0, XN_FLAG_RFC2253);
char *data_start = NULL;
long name_length = BIO_get_mem_data(subject_bio, &data_start);
char *subject = mosquitto__malloc(sizeof(char)*name_length+1);
data_start = NULL;
name_length = BIO_get_mem_data(subject_bio, &data_start);
subject = mosquitto__malloc(sizeof(char)*name_length+1);
if(!subject){
BIO_free(subject_bio);
X509_free(client_cert);
@ -1227,7 +1232,7 @@ int pw__digest(const char *password, const unsigned char *salt, unsigned int sal
digest = EVP_get_digestbyname("sha512");
if(!digest){
// FIXME fprintf(stderr, "Error: Unable to create openssl digest.\n");
/* FIXME fprintf(stderr, "Error: Unable to create openssl digest.\n"); */
return 1;
}
@ -1243,7 +1248,7 @@ int pw__digest(const char *password, const unsigned char *salt, unsigned int sal
digest = EVP_get_digestbyname("sha512");
if(!digest){
// FIXME fprintf(stderr, "Error: Unable to create openssl digest.\n");
/* FIXME fprintf(stderr, "Error: Unable to create openssl digest.\n"); */
return 1;
}

View File

@ -213,6 +213,7 @@ void sys_tree__update(struct mosquitto_db *db, int interval, time_t start_time)
double exponent;
double i_mult;
bool initial_publish;
now = mosquitto_time();
@ -222,7 +223,7 @@ void sys_tree__update(struct mosquitto_db *db, int interval, time_t start_time)
db__messages_easy_queue(db, NULL, "$SYS/broker/uptime", SYS_TREE_QOS, strlen(buf), buf, 1, 60, NULL);
sys_tree__update_clients(db, buf);
bool initial_publish = false;
initial_publish = false;
if(last_update == 0){
initial_publish = true;
last_update = 1;

View File

@ -694,7 +694,7 @@ static int callback_http(struct libwebsocket_context *context,
static void log_wrap(int level, const char *line)
{
char *l = (char *)line;
l[strlen(line)-1] = '\0'; // Remove \n
l[strlen(line)-1] = '\0'; /* Remove \n */
log__printf(NULL, MOSQ_LOG_WEBSOCKETS, "%s", l);
}