From da64ed8d36196524ec78ad4b3b350bed35f4535c Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 11 Feb 2020 21:39:36 +0100 Subject: [PATCH] Fix a memory leak when an invitation file contains an invalid submesh name. Found by Clang's static analyzer. --- src/protocol_auth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/protocol_auth.c b/src/protocol_auth.c index 3676e9cb..6517d9ce 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -230,17 +230,20 @@ static bool receive_invitation_sptps(void *handle, uint8_t type, const void *dat char *submesh_name = packmsg_get_str_dup(&in); if(!strcmp(submesh_name, CORE_MESH)) { + free(submesh_name); c->submesh = NULL; } else { if(!check_id(submesh_name)) { logger(mesh, MESHLINK_ERROR, "Invalid invitation file %s\n", cookie); - abort(); + free(submesh_name); return false; } c->submesh = lookup_or_create_submesh(mesh, submesh_name); + free(submesh_name); if(!c->submesh) { + logger(mesh, MESHLINK_ERROR, "Unknown submesh in invitation file %s\n", cookie); return false; } } @@ -249,7 +252,6 @@ static bool receive_invitation_sptps(void *handle, uint8_t type, const void *dat sptps_send_record(&c->sptps, 0, config.buf, config.len); config_free(&config); - free(submesh_name); c->status.invitation_used = true; -- 2.39.5