commit - 55d7ca587a98f7868d6a835f1ce288e5d02e8cd8bdd28fe9fb28ef22db5e92c7
commit + 22112373e6b083a2b42ad7fc485f3dd9149e7e468f6ad5cad64bb3c1f4b5ad42
blob - 97f43349c2bc957661f3bee6d040b01a21c7f3fc358b5453e16f356f86114427
blob + 2079ea5c128648b4db25b94f5b66ebe11bd5baa75c576421d4beb5a702f2c92d
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif
+#ifndef MINIMUM
+#define MINIMUM(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
static volatile sig_atomic_t sigint_received;
static void
for (i = 0; i < nentries; i++) {
struct got_object_qid *eqid = NULL;
struct got_parsed_tree_entry *pte = &entries[i];
+ struct got_object_id id;
char *p;
if (!S_ISDIR(pte->mode))
continue;
+ id.algo = pte->algo;
+ memcpy(id.hash, pte->id,
+ MINIMUM(pte->digest_len, sizeof(id.hash)));
+ if (got_object_idset_contains(idset, &id))
+ continue;
+
err = got_object_qid_alloc_partial(&eqid);
if (err)
goto done;
- eqid->id.algo = pte->algo;
- memcpy(eqid->id.hash, pte->id, pte->digest_len);
+
+ memcpy(&eqid->id, &id, sizeof(eqid->id));
- if (got_object_idset_contains(idset, &eqid->id)) {
- got_object_qid_free(eqid);
- continue;
- }
-
if (asprintf(&p, "%s%s%s", path,
got_path_is_root_dir(path) ? "" : "/",
pte->name) == -1) {