From 0d25cb58b436915d505e05b9c2e7e66e88a65ef8 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 8 Aug 2018 15:35:42 +0100 Subject: [PATCH] Fix `use_identity_as_username true` not working. Closes #833. Thanks to David Crook and Brice Waegeneire. Bug: https://github.com/eclipse/mosquitto/issues/833 Signed-off-by: Roger A. Light --- ChangeLog.txt | 1 + src/handle_connect.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 52d5215c..b4fcff12 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -20,6 +20,7 @@ Broker: #209. - Fix bridge publishing failing when per_listener_settings was true. Closes #860. +- Fix `use_identity_as_username true` not working. Closes #833. Library: - Fix some places where return codes were incorrect, including to the diff --git a/src/handle_connect.c b/src/handle_connect.c index 0f289616..2a2e09ad 100644 --- a/src/handle_connect.c +++ b/src/handle_connect.c @@ -455,6 +455,11 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context) goto handle_connect_error; } context->username = mosquitto__strdup((char *) ASN1_STRING_data(name_asn1)); + if(!context->username){ + send__connack(context, 0, CONNACK_REFUSED_SERVER_UNAVAILABLE); + rc = MOSQ_ERR_NOMEM; + goto handle_connect_error; + } /* Make sure there isn't an embedded NUL character in the CN */ if ((size_t)ASN1_STRING_length(name_asn1) != strlen(context->username)) { send__connack(context, 0, CONNACK_REFUSED_BAD_USERNAME_PASSWORD);