aboutsummaryrefslogtreecommitdiffstats
path: root/cache_from_tree.c
diff options
context:
space:
mode:
authorCameron Katri <me@cameronkatri.com>2022-06-16 10:17:00 -0400
committerCameron Katri <me@cameronkatri.com>2022-06-16 10:21:50 -0400
commit9ef2c4a87d6fa816639b610313b67b98e983388a (patch)
treef3c5d259a3e0b87c5301ddf23b3185b4de9fbe9f /cache_from_tree.c
parent6a5be2524f0d31a601687e8b5d09b9af92848dac (diff)
downloadtrustcache-9ef2c4a87d6fa816639b610313b67b98e983388a.tar.gz
trustcache-9ef2c4a87d6fa816639b610313b67b98e983388a.tar.zst
trustcache-9ef2c4a87d6fa816639b610313b67b98e983388a.zip
Add support for new version 2 trustcachesHEADmain
Thanks to Linus Henze for reversing the new format https://gist.github.com/LinusHenze/4cd5d7ef057a144cda7234e2c247c056
Diffstat (limited to 'cache_from_tree.c')
-rw-r--r--cache_from_tree.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/cache_from_tree.c b/cache_from_tree.c
index 610653c..723fbac 100644
--- a/cache_from_tree.c
+++ b/cache_from_tree.c
@@ -60,6 +60,12 @@ tccallback(const char *path, const struct stat *sb, __attribute__((unused)) int
cache.entries[cache.num_entries].hash_type = c.h[i].hash_type;
cache.entries[cache.num_entries].flags = 0;
memcpy(cache.entries[cache.num_entries].cdhash, c.h[i].cdhash, CS_CDHASH_LEN);
+ } else if (cache.version == 2) {
+ if ((cache.entries2 = realloc(cache.entries, sizeof(struct trust_cache_entry2) * (cache.num_entries + 1))) == NULL)
+ exit(1);
+ cache.entries2[cache.num_entries].hash_type = c.h[i].hash_type;
+ cache.entries2[cache.num_entries].category = 0;
+ memcpy(cache.entries2[cache.num_entries].cdhash, c.h[i].cdhash, CS_CDHASH_LEN);
}
cache.num_entries++;
}