From: Sam Hartman Date: Thu, 12 Mar 2015 16:11:36 +0000 (-0400) Subject: tids handler fixes X-Git-Tag: 1.5~11 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=trust_router.git;a=commitdiff_plain;h=99682e6203959cd58c7cef274baecf5e34ae6e7d tids handler fixes * use talloc for server responses * bind expiration to right value in statement --- diff --git a/tid/example/tids_main.c b/tid/example/tids_main.c index 0098db5..2cb69b6 100644 --- a/tid/example/tids_main.c +++ b/tid/example/tids_main.c @@ -173,11 +173,11 @@ static int tids_req_handler (TIDS_INSTANCE *tids, /* Allocate a new server block */ - if (NULL == (resp->servers = malloc(sizeof(TID_SRVR_BLK)))){ + if (NULL == (resp->servers = talloc_zero(resp, TID_SRVR_BLK))){ tr_crit("tids_req_handler(): malloc failed."); return -1; } - memset(resp->servers, 0, sizeof(TID_SRVR_BLK)); + resp->num_servers = 1; /* TBD -- Set up the server IP Address */ @@ -231,7 +231,7 @@ static int tids_req_handler (TIDS_INSTANCE *tids, if (req->expiration_interval < 1) req->expiration_interval = 1; g_get_current_time(&resp->servers->key_expiration); - resp->servers->key_expiration.tv_sec += req->expiration_interval * 60 /*in minutes*/; + resp->servers->key_expiration.tv_sec += req->expi5ration_interval * 60 /*in minutes*/; if (NULL != insert_stmt) { int sqlite3_result; @@ -239,7 +239,7 @@ static int tids_req_handler (TIDS_INSTANCE *tids, sqlite3_bind_text(insert_stmt, 1, key_id, -1, SQLITE_TRANSIENT); sqlite3_bind_blob(insert_stmt, 2, s_keybuf, s_keylen, SQLITE_TRANSIENT); sqlite3_bind_blob(insert_stmt, 3, pub_digest, pub_digest_len, SQLITE_TRANSIENT); - sqlite3_bind_text(insert_stmt, 3, expiration_str, -1, SQLITE_TRANSIENT); + sqlite3_bind_text(insert_stmt, 4, expiration_str, -1, SQLITE_TRANSIENT); sqlite3_result = sqlite3_step(insert_stmt); if (SQLITE_DONE != sqlite3_result) tr_crit("sqlite3: failed to write to database");