From a106ecc319f4c6427ee0fce5cec90d86a9cc7987 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Sun, 7 Apr 2019 17:48:46 +0100 Subject: [PATCH] Fix #321 was not correctly implemented While #321 prevented a core dump, that fix still caused memory corruption. src/coap_gnutls.c: Correct the code to correctly NULL terminate the created username. --- src/coap_gnutls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coap_gnutls.c b/src/coap_gnutls.c index 08f3099c..cbfdffbd 100644 --- a/src/coap_gnutls.c +++ b/src/coap_gnutls.c @@ -404,7 +404,7 @@ psk_client_callback(gnutls_session_t g_session, *username = gnutls_malloc(identity_len+1); if (*username) { memcpy(*username, identity, identity_len); - username[identity_len] = '\0'; + (*username)[identity_len] = '\0'; } key->data = gnutls_malloc(psk_len);