From 2288b178e612386e7a75471c8861c3f6d81c300d Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sat, 21 May 2022 23:44:49 -0400 Subject: Add tc remove and append -f flags Also fix some conflicting types to hopefully prevent possible overflows. --- create.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'create.c') diff --git a/create.c b/create.c index a19d7f3..955c833 100644 --- a/create.c +++ b/create.c @@ -71,9 +71,8 @@ tccreate(int argc, char **argv) argc -= optind; argv += optind; - if (argc == 0) { + if (argc == 0) return -1; - } for (int i = 1; i < argc; i++) { append = cache_from_tree(argv[i], cache.version); @@ -81,14 +80,14 @@ tccreate(int argc, char **argv) if ((cache.hashes = realloc(cache.hashes, sizeof(trust_cache_hash0) * (cache.num_entries + append.num_entries))) == NULL) exit(1); - for (int j = 0; j < append.num_entries; j++) { + for (uint32_t j = 0; j < append.num_entries; j++) { memcpy(cache.hashes[cache.num_entries + j], append.hashes[j], CS_CDHASH_LEN); } } else if (append.version == 1) { if ((cache.entries = realloc(cache.entries, sizeof(struct trust_cache_entry1) * (cache.num_entries + append.num_entries))) == NULL) exit(1); - for (int j = 0; j < append.num_entries; j++) { + for (uint32_t j = 0; j < append.num_entries; j++) { cache.entries[cache.num_entries + j].hash_type = append.entries[j].hash_type; cache.entries[cache.num_entries + j].flags = append.entries[j].flags; memcpy(cache.entries[cache.num_entries + j].cdhash, append.entries[j].cdhash, CS_CDHASH_LEN); @@ -115,7 +114,7 @@ tccreate(int argc, char **argv) cache.version = le32toh(cache.version); cache.num_entries = le32toh(cache.num_entries); - for (int i = 0; i < cache.num_entries; i++) { + for (uint32_t i = 0; i < cache.num_entries; i++) { if (cache.version == 1) fwrite(&cache.entries[i], sizeof(struct trust_cache_entry1), 1, f); else if (cache.version == 0) -- cgit v1.2.3-56-ge451