diff options
author | Franklin Wei <me@fwei.tk> | 2018-06-18 12:56:50 -0400 |
---|---|---|
committer | Franklin Wei <me@fwei.tk> | 2018-06-18 12:56:50 -0400 |
commit | 3a4365ac140bef2cd29b456f530660184a0fd000 (patch) | |
tree | ea5a7255c11ddda2f8b51980b6bdd5da3f076da4 /service_provider.c | |
parent | f7d0c06fe723fe8be799935238136e2a57a40d36 (diff) | |
download | csaa-3a4365ac140bef2cd29b456f530660184a0fd000.zip csaa-3a4365ac140bef2cd29b456f530660184a0fd000.tar.gz csaa-3a4365ac140bef2cd29b456f530660184a0fd000.tar.bz2 csaa-3a4365ac140bef2cd29b456f530660184a0fd000.tar.xz |
Fix memory leak; also add further test for file retrieval
Diffstat (limited to 'service_provider.c')
-rw-r--r-- | service_provider.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/service_provider.c b/service_provider.c index b534950..0065512 100644 --- a/service_provider.c +++ b/service_provider.c @@ -526,9 +526,9 @@ struct version_info sp_fileinfo(struct service_provider *sp, comp, orders, sp->iomt->mt_logleaves, &rv1_hmac, 0, NULL, NULL); - free(orders); - free(compidx); free(comp); + free(compidx); + free(orders); } else { @@ -542,6 +542,10 @@ struct version_info sp_fileinfo(struct service_provider *sp, comp, orders, sp->iomt->mt_logleaves, NULL, file_idx, &rv1, &rv1_hmac); + + free(comp); + free(compidx); + free(orders); } return tm_verify_file(sp->tm, @@ -597,7 +601,7 @@ void sp_test(void) check("File creation", ack_verify(&req, "a", 1, ack_hmac)); -#define N_MODIFY 1000 +#define N_MODIFY 10000 start = clock(); for(int i = 0; i < N_MODIFY; ++i) req = sp_modifyfile(sp, 1, "a", 1, 1, hash_null, hash_null, "contents", 8, &ack_hmac); @@ -619,10 +623,20 @@ void sp_test(void) check("Authenticated denial 2", hash_equals(hmac, hmac_sha256(&vi, sizeof(vi), "a", 1))); /* check in range */ - vi = sp_fileinfo(sp, 1, 1, 1, &hmac); + vi = sp_fileinfo(sp, + 1, /* user */ + 1, /* file */ + 1, /* version */ + &hmac); check("File info retrieval 1", hash_equals(hmac, hmac_sha256(&vi, sizeof(vi), "a", 1))); - struct version_info correct = { 1, 1001, 1, 1 }; + hash_t gamma = sha256("contents", 8); + hash_t kf = hash_null; + hash_t lambda = hmac_sha256(&gamma, sizeof(gamma), + &kf, sizeof(kf)); + + struct version_info correct = { 1, N_MODIFY + 1, 1, N_MODIFY, lambda }; + check("File info retrieval 2", !memcmp(&correct, &vi, sizeof(vi))); } if(logleaves < 5) |