Simplify.

pull/211/merge
Roger A. Light 12 years ago
parent 87579e0cac
commit 85af9bdd9a

@ -156,12 +156,11 @@ int mqtt3_handle_connect(struct mosquitto_db *db, struct mosquitto *context)
}else{ /* mqtt311 */ }else{ /* mqtt311 */
_mosquitto_free(client_id); _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); _mosquitto_send_connack(context, 0, CONNACK_REFUSED_IDENTIFIER_REJECTED);
mqtt3_context_disconnect(db, context); mqtt3_context_disconnect(db, context);
return MOSQ_ERR_PROTOCOL; return MOSQ_ERR_PROTOCOL;
} }else{
if(db->config->allow_zero_length_clientid == true){
client_id = (char *)_mosquitto_calloc(65 + db->config->auto_id_prefix_len, sizeof(char)); client_id = (char *)_mosquitto_calloc(65 + db->config->auto_id_prefix_len, sizeof(char));
if(!client_id){ if(!client_id){
mqtt3_context_disconnect(db, context); 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+db->config->auto_id_prefix_len] = (rand()%73)+48;
} }
client_id[i] = '\0'; client_id[i] = '\0';
}else{
_mosquitto_send_connack(context, 0, CONNACK_REFUSED_IDENTIFIER_REJECTED);
mqtt3_context_disconnect(db, context);
return MOSQ_ERR_PROTOCOL;
} }
} }
} }

Loading…
Cancel
Save