From 85af9bdd9a314c470d2ff5b7948c3d5c43c4bc86 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sat, 31 May 2014 22:12:20 +0100 Subject: [PATCH] Simplify. --- src/read_handle_server.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/read_handle_server.c b/src/read_handle_server.c index e4f96c22..1c8ab7a2 100644 --- a/src/read_handle_server.c +++ b/src/read_handle_server.c @@ -156,12 +156,11 @@ int mqtt3_handle_connect(struct mosquitto_db *db, struct mosquitto *context) }else{ /* mqtt311 */ _mosquitto_free(client_id); - if(clean_session == 0){ + if(clean_session == 0 || db->config->allow_zero_length_clientid == false){ _mosquitto_send_connack(context, 0, CONNACK_REFUSED_IDENTIFIER_REJECTED); mqtt3_context_disconnect(db, context); return MOSQ_ERR_PROTOCOL; - } - if(db->config->allow_zero_length_clientid == true){ + }else{ client_id = (char *)_mosquitto_calloc(65 + db->config->auto_id_prefix_len, sizeof(char)); if(!client_id){ mqtt3_context_disconnect(db, context); @@ -172,10 +171,6 @@ int mqtt3_handle_connect(struct mosquitto_db *db, struct mosquitto *context) client_id[i+db->config->auto_id_prefix_len] = (rand()%73)+48; } client_id[i] = '\0'; - }else{ - _mosquitto_send_connack(context, 0, CONNACK_REFUSED_IDENTIFIER_REJECTED); - mqtt3_context_disconnect(db, context); - return MOSQ_ERR_PROTOCOL; } } }