From 63277aad0b21ad4742bc4e71e88043fd7ccb74bf Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 17 Nov 2020 16:10:01 +0000 Subject: [PATCH] dynsec: setClientId should cope with missing/empty client id. --- plugins/dynamic-security/clients.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/dynamic-security/clients.c b/plugins/dynamic-security/clients.c index 000a349d..bdd3969e 100644 --- a/plugins/dynamic-security/clients.c +++ b/plugins/dynamic-security/clients.c @@ -575,10 +575,14 @@ int dynsec_clients__process_set_id(cJSON *j_responses, struct mosquitto *context return MOSQ_ERR_SUCCESS; } - clientid_heap = mosquitto_strdup(clientid); - if(clientid_heap == NULL){ - dynsec__command_reply(j_responses, context, "setClientId", "Internal error", correlation_data); - return MOSQ_ERR_NOMEM; + if(clientid != NULL && strlen(clientid) > 0){ + clientid_heap = mosquitto_strdup(clientid); + if(clientid_heap == NULL){ + dynsec__command_reply(j_responses, context, "setClientId", "Internal error", correlation_data); + return MOSQ_ERR_NOMEM; + } + }else{ + clientid_heap = NULL; } mosquitto_free(client->clientid);