]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
HS 2.0 server: Fix couple of memory leaks
authorJouni Malinen <jouni@codeaurora.org>
Tue, 4 Dec 2018 12:12:44 +0000 (14:12 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 4 Dec 2018 12:12:44 +0000 (14:12 +0200)
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
hs20/server/spp_server.c

index 81cd6ed294f4e2bc809f49b6bdac73ff4e2e2fb6..f4e390e91dd65070609bc9caefdb9bb1904fd297 100644 (file)
@@ -754,8 +754,10 @@ static xml_node_t * build_sub_rem_resp(struct hs20_svc *ctx,
        }
 
        cert = db_get_val(ctx, user, realm, "cert", dmacc);
-       if (cert && cert[0] == '\0')
+       if (cert && cert[0] == '\0') {
+               os_free(cert);
                cert = NULL;
+       }
        if (cert) {
                cred = build_credential_cert(ctx, real_user ? real_user : user,
                                             realm, cert);
@@ -781,6 +783,7 @@ static xml_node_t * build_sub_rem_resp(struct hs20_svc *ctx,
        free(real_user);
        if (!cred) {
                debug_print(ctx, 1, "Could not build credential");
+               os_free(cert);
                return NULL;
        }
 
@@ -789,6 +792,7 @@ static xml_node_t * build_sub_rem_resp(struct hs20_svc *ctx,
                                                NULL);
        if (spp_node == NULL) {
                debug_print(ctx, 1, "Could not build sppPostDevDataResponse");
+               os_free(cert);
                return NULL;
        }
 
@@ -799,6 +803,7 @@ static xml_node_t * build_sub_rem_resp(struct hs20_svc *ctx,
        if (add_update_node(ctx, spp_node, ns, buf, cred) < 0) {
                debug_print(ctx, 1, "Could not add update node");
                xml_node_free(ctx->xml, spp_node);
+               os_free(cert);
                return NULL;
        }
 
@@ -817,6 +822,7 @@ static xml_node_t * build_sub_rem_resp(struct hs20_svc *ctx,
                db_add_session(ctx, user, realm, session_id, new_pw, NULL,
                               UPDATE_PASSWORD, NULL);
        }
+       os_free(cert);
 
        return spp_node;
 }