From: Tollef Fog Heen Date: Mon, 12 Oct 2009 06:17:54 +0000 (+0200) Subject: Free alloced memory X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0810cea2c93d812a01a9399e0d248f27d0199fdb;p=yubikey-server-c Free alloced memory --- diff --git a/src/main.c b/src/main.c index 2e8be42..1449ea9 100644 --- a/src/main.c +++ b/src/main.c @@ -310,8 +310,7 @@ static int handle_request(void * UNUSED(data), /* XXX: Something blew up, assume no such ID */ status = "NO_SUCH_CLIENT"; send_response(conn, NULL, status, NULL, timestamp); - /* XXX free memory */ - return MHD_YES; + goto free_mem; } if (otp == NULL) { @@ -320,8 +319,7 @@ static int handle_request(void * UNUSED(data), signature = sign_request(shared_secret, shared_secret_len, info, status, timestamp); send_response(conn, signature, status, NULL, timestamp); - /* XXX free memory */ - return MHD_YES; + goto free_mem; } if (! yubikey_modhex_p(otp)) { @@ -329,8 +327,7 @@ static int handle_request(void * UNUSED(data), signature = sign_request(shared_secret, shared_secret_len, NULL, status, timestamp); send_response(conn, signature, status, NULL, timestamp); - /* XXX free memory */ - return MHD_YES; + goto free_mem; } /* XXX: If h exists, verify. FIXME */ @@ -350,8 +347,7 @@ static int handle_request(void * UNUSED(data), NULL, status, timestamp); send_response(conn, signature, status, NULL, timestamp); - /* XXX FIXME free memory */ - fprintf(stderr, "BAD TOKEN\n"); + goto free_mem; return MHD_YES; } if (yubikey_counter(token.ctr) < stats.session_counter || @@ -362,12 +358,14 @@ static int handle_request(void * UNUSED(data), signature = sign_request(shared_secret, shared_secret_len, NULL, status, timestamp); send_response(conn, signature, status, NULL, timestamp); - /* XXX FIXME free memory */ fprintf(stderr, "replay\n"); - return MHD_YES; + goto free_mem; } /* Update status, if appropriate */ + free(stats.public_id); + free(stats.secret_uid); + free(stats.secret_key); memset(&stats, 0, sizeof(struct ykc_stats)); stats.session_counter = yubikey_counter(token.ctr); stats.session_use = token.use; @@ -378,6 +376,15 @@ static int handle_request(void * UNUSED(data), signature = sign_request(shared_secret, shared_secret_len, NULL, status, timestamp); send_response(conn, signature, status, NULL, timestamp); +free_mem: + free(timestamp); + free(shared_secret); + free(signature); + free(stats.public_id); + free(stats.secret_uid); + free(stats.secret_key); + free(uid); + free(otp_token); return MHD_YES; }