Merge branch 'coverity-fixes' into fixes
This commit is contained in:
commit
2a8c1d03f5
@ -27,7 +27,6 @@ struct userdata__callback {
|
||||
int (*callback)(struct mosquitto *, void *, const struct mosquitto_message *);
|
||||
void *userdata;
|
||||
int qos;
|
||||
int rc;
|
||||
};
|
||||
|
||||
struct userdata__simple {
|
||||
@ -168,7 +167,6 @@ libmosq_EXPORT int mosquitto_subscribe_callback(
|
||||
|
||||
cb_userdata.topic = topic;
|
||||
cb_userdata.qos = qos;
|
||||
cb_userdata.rc = 0;
|
||||
cb_userdata.userdata = userdata;
|
||||
cb_userdata.callback = callback;
|
||||
|
||||
@ -214,14 +212,6 @@ libmosq_EXPORT int mosquitto_subscribe_callback(
|
||||
}
|
||||
rc = mosquitto_loop_forever(mosq, -1, 1);
|
||||
mosquitto_destroy(mosq);
|
||||
if(cb_userdata.rc){
|
||||
rc = cb_userdata.rc;
|
||||
}
|
||||
//if(!rc && cb_userdata.max_msg_count == 0){
|
||||
//return MOSQ_ERR_SUCCESS;
|
||||
//}else{
|
||||
//return rc;
|
||||
//}
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -567,7 +567,6 @@ int mosquitto_sub_topic_tokenise(const char *subtopic, char ***topics, int *coun
|
||||
if(!(*topics)) return MOSQ_ERR_NOMEM;
|
||||
|
||||
start = 0;
|
||||
stop = 0;
|
||||
hier = 0;
|
||||
|
||||
for(i=0; i<len+1; i++){
|
||||
|
@ -153,6 +153,6 @@ enum mqtt5_sub_options {
|
||||
MQTT_SUB_OPT_SEND_RETAIN_NEVER = 0x20,
|
||||
};
|
||||
|
||||
#define MQTT_MAX_PAYLOAD 268435455
|
||||
#define MQTT_MAX_PAYLOAD 268435455U
|
||||
|
||||
#endif
|
||||
|
@ -39,24 +39,24 @@ Contributors:
|
||||
#include "send_mosq.h"
|
||||
#include "util_mosq.h"
|
||||
|
||||
#define SOCKS_AUTH_NONE 0x00
|
||||
#define SOCKS_AUTH_GSS 0x01
|
||||
#define SOCKS_AUTH_USERPASS 0x02
|
||||
#define SOCKS_AUTH_NO_ACCEPTABLE 0xFF
|
||||
#define SOCKS_AUTH_NONE 0x00U
|
||||
#define SOCKS_AUTH_GSS 0x01U
|
||||
#define SOCKS_AUTH_USERPASS 0x02U
|
||||
#define SOCKS_AUTH_NO_ACCEPTABLE 0xFFU
|
||||
|
||||
#define SOCKS_ATYPE_IP_V4 1 /* four bytes */
|
||||
#define SOCKS_ATYPE_DOMAINNAME 3 /* one byte length, followed by fqdn no null, 256 max chars */
|
||||
#define SOCKS_ATYPE_IP_V6 4 /* 16 bytes */
|
||||
#define SOCKS_ATYPE_IP_V4 1U /* four bytes */
|
||||
#define SOCKS_ATYPE_DOMAINNAME 3U /* one byte length, followed by fqdn no null, 256 max chars */
|
||||
#define SOCKS_ATYPE_IP_V6 4U /* 16 bytes */
|
||||
|
||||
#define SOCKS_REPLY_SUCCEEDED 0x00
|
||||
#define SOCKS_REPLY_GENERAL_FAILURE 0x01
|
||||
#define SOCKS_REPLY_CONNECTION_NOT_ALLOWED 0x02
|
||||
#define SOCKS_REPLY_NETWORK_UNREACHABLE 0x03
|
||||
#define SOCKS_REPLY_HOST_UNREACHABLE 0x04
|
||||
#define SOCKS_REPLY_CONNECTION_REFUSED 0x05
|
||||
#define SOCKS_REPLY_TTL_EXPIRED 0x06
|
||||
#define SOCKS_REPLY_COMMAND_NOT_SUPPORTED 0x07
|
||||
#define SOCKS_REPLY_ADDRESS_TYPE_NOT_SUPPORTED 0x08
|
||||
#define SOCKS_REPLY_SUCCEEDED 0x00U
|
||||
#define SOCKS_REPLY_GENERAL_FAILURE 0x01U
|
||||
#define SOCKS_REPLY_CONNECTION_NOT_ALLOWED 0x02U
|
||||
#define SOCKS_REPLY_NETWORK_UNREACHABLE 0x03U
|
||||
#define SOCKS_REPLY_HOST_UNREACHABLE 0x04U
|
||||
#define SOCKS_REPLY_CONNECTION_REFUSED 0x05U
|
||||
#define SOCKS_REPLY_TTL_EXPIRED 0x06U
|
||||
#define SOCKS_REPLY_COMMAND_NOT_SUPPORTED 0x07U
|
||||
#define SOCKS_REPLY_ADDRESS_TYPE_NOT_SUPPORTED 0x08U
|
||||
|
||||
int mosquitto_socks5_set(struct mosquitto *mosq, const char *host, int port, const char *username, const char *password)
|
||||
{
|
||||
|
@ -974,7 +974,6 @@ int db__message_write(struct mosquitto_db *db, struct mosquitto *context)
|
||||
|
||||
DL_FOREACH_SAFE(context->msgs_in.inflight, tail, tmp){
|
||||
msg_count++;
|
||||
expiry_interval = 0;
|
||||
if(tail->store->message_expiry_time){
|
||||
if(now == 0){
|
||||
now = time(NULL);
|
||||
@ -983,19 +982,9 @@ int db__message_write(struct mosquitto_db *db, struct mosquitto *context)
|
||||
/* Message is expired, must not send. */
|
||||
db__message_remove(db, &context->msgs_in, tail);
|
||||
continue;
|
||||
}else{
|
||||
expiry_interval = tail->store->message_expiry_time - now;
|
||||
}
|
||||
}
|
||||
mid = tail->mid;
|
||||
retries = tail->dup;
|
||||
retain = tail->retain;
|
||||
topic = tail->store->topic;
|
||||
qos = tail->qos;
|
||||
payloadlen = tail->store->payloadlen;
|
||||
payload = UHPA_ACCESS_PAYLOAD(tail->store);
|
||||
cmsg_props = tail->properties;
|
||||
store_props = tail->store->properties;
|
||||
|
||||
switch(tail->state){
|
||||
case mosq_ms_send_pubrec:
|
||||
@ -1032,7 +1021,6 @@ int db__message_write(struct mosquitto_db *db, struct mosquitto *context)
|
||||
|
||||
DL_FOREACH_SAFE(context->msgs_out.inflight, tail, tmp){
|
||||
msg_count++;
|
||||
expiry_interval = 0;
|
||||
if(tail->store->message_expiry_time){
|
||||
if(now == 0){
|
||||
now = time(NULL);
|
||||
@ -1044,6 +1032,8 @@ int db__message_write(struct mosquitto_db *db, struct mosquitto *context)
|
||||
}else{
|
||||
expiry_interval = tail->store->message_expiry_time - now;
|
||||
}
|
||||
}else{
|
||||
expiry_interval = 0;
|
||||
}
|
||||
mid = tail->mid;
|
||||
retries = tail->dup;
|
||||
|
@ -498,10 +498,11 @@ int mosquitto_main_loop(struct mosquitto_db *db, mosq_sock_t *listensock, int li
|
||||
}
|
||||
context = NULL;
|
||||
HASH_FIND(hh_sock, db->contexts_by_sock, &(ev.data.fd), sizeof(mosq_sock_t), context);
|
||||
if(!context) {
|
||||
if(context){
|
||||
context->events = EPOLLIN;
|
||||
}else{
|
||||
log__printf(NULL, MOSQ_LOG_ERR, "Error in epoll accepting: no context");
|
||||
}
|
||||
context->events = EPOLLIN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -333,6 +333,10 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if(listensock == NULL){
|
||||
log__printf(NULL, MOSQ_LOG_ERR, "Error: Unable to start any listening sockets, exiting.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = drop_privileges(&config, false);
|
||||
if(rc != MOSQ_ERR_SUCCESS) return rc;
|
||||
@ -417,18 +421,16 @@ int main(int argc, char *argv[])
|
||||
|
||||
db__close(&int_db);
|
||||
|
||||
if(listensock){
|
||||
for(i=0; i<listensock_count; i++){
|
||||
if(listensock[i] != INVALID_SOCKET){
|
||||
for(i=0; i<listensock_count; i++){
|
||||
if(listensock[i] != INVALID_SOCKET){
|
||||
#ifndef WIN32
|
||||
close(listensock[i]);
|
||||
close(listensock[i]);
|
||||
#else
|
||||
closesocket(listensock[i]);
|
||||
closesocket(listensock[i]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
mosquitto__free(listensock);
|
||||
}
|
||||
mosquitto__free(listensock);
|
||||
|
||||
mosquitto_security_module_cleanup(&int_db);
|
||||
|
||||
|
18
src/subs.c
18
src/subs.c
@ -216,8 +216,8 @@ static struct sub__token *sub__topic_append(struct sub__token **tail, struct sub
|
||||
static int sub__topic_tokenise(const char *subtopic, struct sub__token **topics)
|
||||
{
|
||||
struct sub__token *new_topic, *tail = NULL;
|
||||
int len;
|
||||
int start, stop, tlen;
|
||||
size_t len;
|
||||
size_t start, stop, tlen;
|
||||
int i;
|
||||
char *topic;
|
||||
int count = 0;
|
||||
@ -225,13 +225,16 @@ static int sub__topic_tokenise(const char *subtopic, struct sub__token **topics)
|
||||
assert(subtopic);
|
||||
assert(topics);
|
||||
|
||||
len = strlen(subtopic);
|
||||
if(len == 0){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(subtopic[0] != '$'){
|
||||
new_topic = sub__topic_append(&tail, topics, "");
|
||||
if(!new_topic) goto cleanup;
|
||||
}
|
||||
|
||||
len = strlen(subtopic);
|
||||
|
||||
if(subtopic[0] == '/'){
|
||||
new_topic = sub__topic_append(&tail, topics, "");
|
||||
if(!new_topic) goto cleanup;
|
||||
@ -241,7 +244,6 @@ static int sub__topic_tokenise(const char *subtopic, struct sub__token **topics)
|
||||
start = 0;
|
||||
}
|
||||
|
||||
stop = 0;
|
||||
for(i=start; i<len+1; i++){
|
||||
if(subtopic[i] == '/' || subtopic[i] == '\0'){
|
||||
stop = i;
|
||||
@ -269,7 +271,11 @@ static int sub__topic_tokenise(const char *subtopic, struct sub__token **topics)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
if(*topics != NULL){
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else{
|
||||
return 1;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
tail = *topics;
|
||||
|
Loading…
Reference in New Issue
Block a user