commit a3dc7ed231aec149a7f09125e4cd2d37480df44d from: Omar Polo date: Fri Jul 12 19:22:45 2024 UTC prepare got_object_parse_tree for sha256 commit - f540978827bdd3808e5374d643f4eed4367e556a commit + a3dc7ed231aec149a7f09125e4cd2d37480df44d blob - 871d597f71d021f4f8459895c0dd10256623af34 blob + 8817fd84008c7497a2a44f44f5111f20ad3414e4 --- lib/dial.c +++ lib/dial.c @@ -39,6 +39,7 @@ #include "got_lib_dial.h" #include "got_lib_delta.h" +#include "got_lib_hash.h" #include "got_lib_object.h" #include "got_lib_privsep.h" #include "got_dial.h" blob - 05babbcb9ae24c765e1ed59bf0cb51d45de5aec7 blob + b6b4541f9756fd1fc9eb3329cd32a375b2a4b874 --- lib/got_lib_object_parse.h +++ lib/got_lib_object_parse.h @@ -31,9 +31,11 @@ struct got_parsed_tree_entry { size_t namelen; /* strlen(name) */ mode_t mode; /* Mode parsed from tree buffer. */ uint8_t *id; /* Points to ID in parsed tree buffer. */ + size_t idlen; + int algo; }; const struct got_error *got_object_parse_tree_entry( - struct got_parsed_tree_entry *, size_t *, char *, size_t, size_t); + struct got_parsed_tree_entry *, size_t *, char *, size_t, size_t, enum got_hash_algorithm); const struct got_error *got_object_parse_tree(struct got_parsed_tree_entry **, size_t *, size_t *, uint8_t *, size_t, enum got_hash_algorithm); const struct got_error *got_object_read_tree(struct got_parsed_tree_entry **, blob - 9365381c6d173fbb3fedfb6b7d428db95f6e93f5 blob + 0d7024446375ed47e5fbc7c9830b2a1d63feee67 --- lib/got_lib_privsep.h +++ lib/got_lib_privsep.h @@ -260,7 +260,8 @@ struct got_imsg_commit_object { } __attribute__((__packed__)); struct got_imsg_tree_entry { - char id[SHA1_DIGEST_LENGTH]; + char id[GOT_HASH_DIGEST_MAXLEN]; + int algo; mode_t mode; size_t namelen; /* Followed by namelen bytes of entry's name, not NUL-terminated. */ blob - a17fad35a4e3a657892518b204167bccb6b24289 blob + 5e65af8b44e92ed67e01cb75e6067361e2495821 --- lib/object_open_privsep.c +++ lib/object_open_privsep.c @@ -42,6 +42,7 @@ #include "got_lib_delta.h" #include "got_lib_object.h" +#include "got_lib_hash.h" #include "got_lib_privsep.h" #include "got_lib_object_cache.h" #include "got_lib_pack.h" blob - 0aafbffd522a53c07caf5219f5e6e6133d39d5eb blob + 20b5ff506329860f970e4834b4b5ec6f9d3e38f4 --- lib/object_parse.c +++ lib/object_parse.c @@ -764,7 +764,7 @@ got_object_tree_close(struct got_tree_object *tree) const struct got_error * got_object_parse_tree_entry(struct got_parsed_tree_entry *pte, size_t *elen, - char *buf, size_t maxlen, size_t idlen) + char *buf, size_t maxlen, size_t idlen, enum got_hash_algorithm algo) { char *p, *space; @@ -795,6 +795,8 @@ got_object_parse_tree_entry(struct got_parsed_tree_ent pte->namelen = strlen(pte->name); buf += *elen; pte->id = buf; + pte->idlen = idlen; + pte->algo = algo; *elen += idlen; return NULL; } @@ -840,7 +842,7 @@ got_object_parse_tree(struct got_parsed_tree_entry **e pte = &(*entries)[*nentries]; err = got_object_parse_tree_entry(pte, &elen, buf, remain, - digest_len); + digest_len, algo); if (err) goto done; buf += elen; blob - 21a33372de3f7d23116d9edeec23858bec4f935d blob + 609522bd15cada03e452f340e81a8ffce06233e2 --- lib/pack_create_privsep.c +++ lib/pack_create_privsep.c @@ -40,6 +40,7 @@ #include "got_path.h" #include "got_lib_delta.h" +#include "got_lib_hash.h" #include "got_lib_object.h" #include "got_lib_object_cache.h" #include "got_lib_object_idset.h" blob - f4f6c729dd161c635672dc12af8bdf34b2c7721e blob + 2859f8d7a34b7bfa1cd69245c171bbc2b93a425b --- lib/patch.c +++ lib/patch.c @@ -51,9 +51,9 @@ #include "got_lib_delta.h" #include "got_lib_diff.h" +#include "got_lib_hash.h" #include "got_lib_object.h" #include "got_lib_privsep.h" -#include "got_lib_hash.h" #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) blob - 9fc1dd22c6d4e2c1868cd493424a0d5b4fe5ed5a blob + 2ba330c0f358f16e376a462ff551e80515cc1def --- lib/privsep.c +++ lib/privsep.c @@ -1452,10 +1452,16 @@ send_tree_entries_batch(struct imsgbuf *ibuf, return got_error_from_errno("imsg_add TREE_ENTRY"); for (i = idx0; i <= idxN; i++) { + static const char gap[12]; /* for sha1 inside sha256 align */ struct got_parsed_tree_entry *pte = &entries[i]; /* Keep in sync with struct got_imsg_tree_entry definition! */ - if (imsg_add(wbuf, pte->id, SHA1_DIGEST_LENGTH) == -1) + if (imsg_add(wbuf, pte->id, pte->idlen) == -1) + return got_error_from_errno("imsg_add TREE_ENTRY"); + if (pte->algo == GOT_HASH_SHA1 && + imsg_add(wbuf, gap, sizeof(gap)) == -1) + return got_error_from_errno("imsg_add TREE_ENTRY"); + if (imsg_add(wbuf, &pte->algo, sizeof(pte->algo)) == -1) return got_error_from_errno("imsg_add TREE_ENTRY"); if (imsg_add(wbuf, &pte->mode, sizeof(pte->mode)) == -1) return got_error_from_errno("imsg_add TREE_ENTRY"); @@ -1579,7 +1585,7 @@ recv_tree_entries(void *data, size_t datalen, struct g te_name = buf + sizeof(ite); memcpy(te->name, te_name, ite.namelen); te->name[ite.namelen] = '\0'; - memcpy(te->id.sha1, ite.id, SHA1_DIGEST_LENGTH); + memcpy(te->id.sha1, ite.id, sizeof(te->id.sha1)); te->mode = ite.mode; te->idx = *nentries; (*nentries)++; blob - 6f95c0f3be48676947b73e0f94d3c4cb8f97d06e blob + fbd9ee7326aed4db2e259b9834e9dde9dc4fada1 --- lib/read_gitconfig_privsep.c +++ lib/read_gitconfig_privsep.c @@ -38,6 +38,7 @@ #include "got_path.h" #include "got_lib_delta.h" +#include "got_lib_hash.h" #include "got_lib_object.h" #include "got_lib_object_cache.h" #include "got_lib_privsep.h" blob - 05502a62412786df6c1eb1c76b4411c0072d3054 blob + 3fcaa54542762f35cd1254c5af1d6e8c73100b77 --- lib/read_gotconfig_privsep.c +++ lib/read_gotconfig_privsep.c @@ -35,6 +35,7 @@ #include "got_repository.h" #include "got_lib_delta.h" +#include "got_lib_hash.h" #include "got_lib_object.h" #include "got_lib_privsep.h" #include "got_lib_gotconfig.h" blob - 37bc0f5633b6a62f7d4a4d4b044b9301b502b0bd blob + c2bffe1a9e66be605e77b82a0240a6e4bf6ac481 --- lib/repository.c +++ lib/repository.c @@ -55,13 +55,13 @@ #include "got_lib_delta.h" #include "got_lib_delta_cache.h" +#include "got_lib_hash.h" #include "got_lib_inflate.h" #include "got_lib_object.h" #include "got_lib_object_parse.h" #include "got_lib_object_create.h" #include "got_lib_pack.h" #include "got_lib_privsep.h" -#include "got_lib_hash.h" #include "got_lib_object_cache.h" #include "got_lib_repository.h" #include "got_lib_gotconfig.h" blob - 3e6484604a0fd85e52307e35003a601798197c14 blob + 10594688c987e7923021d20f92967f9f61235ada --- lib/repository_admin.c +++ lib/repository_admin.c @@ -46,6 +46,7 @@ #include "got_path.h" #include "got_lib_delta.h" +#include "got_lib_hash.h" #include "got_lib_object.h" #include "got_lib_object_idset.h" #include "got_lib_object_cache.h" @@ -54,7 +55,6 @@ #include "got_lib_repository.h" #include "got_lib_ratelimit.h" #include "got_lib_pack_create.h" -#include "got_lib_hash.h" #include "got_lib_lockfile.h" #ifndef nitems blob - 7f75afa1f1f24fe910ee48fc4058be6cef03a8ee blob + d3d7dc3684a3c02b02da73a5df88a62ba3f3a9c4 --- libexec/got-read-commit/got-read-commit.c +++ libexec/got-read-commit/got-read-commit.c @@ -35,12 +35,12 @@ #include "got_object.h" #include "got_lib_delta.h" +#include "got_lib_hash.h" #include "got_lib_inflate.h" #include "got_lib_object.h" #include "got_lib_object_parse.h" #include "got_lib_object_qid.h" #include "got_lib_privsep.h" -#include "got_lib_hash.h" static volatile sig_atomic_t sigint_received; blob - 9a5bac7eae6301e9090148ee2ec8d0dbdaf69237 blob + c5c7e195b363bff1a04075a31e61fe76a6330b8d --- libexec/got-read-gitconfig/got-read-gitconfig.c +++ libexec/got-read-gitconfig/got-read-gitconfig.c @@ -36,6 +36,7 @@ #include "got_repository.h" #include "got_lib_delta.h" +#include "got_lib_hash.h" #include "got_lib_object.h" #include "got_lib_privsep.h" #include "got_lib_gitconfig.h" blob - 43d3bfb7594fb0bc0bbe2d802c057ea1f4ec4a5e blob + 44ae987193ae5d6ef34fa98f645dd0ab17cb8338 --- libexec/got-read-gotconfig/got-read-gotconfig.c +++ libexec/got-read-gotconfig/got-read-gotconfig.c @@ -37,6 +37,7 @@ #include "got_repository.h" #include "got_lib_delta.h" +#include "got_lib_hash.h" #include "got_lib_object.h" #include "got_lib_privsep.h" blob - 0270712db89ff118f330ae2524053b281b8d46e2 blob + 18d9dcc1df01508d3904bf3d5d072fc2b0d52438 --- libexec/got-read-object/got-read-object.c +++ libexec/got-read-object/got-read-object.c @@ -35,11 +35,11 @@ #include "got_object.h" #include "got_lib_delta.h" +#include "got_lib_hash.h" #include "got_lib_inflate.h" #include "got_lib_object.h" #include "got_lib_object_parse.h" #include "got_lib_privsep.h" -#include "got_lib_hash.h" #ifndef nitems #define nitems(_a) (sizeof(_a) / sizeof((_a)[0])) blob - 09220338d83b41d5d49414631079238d7ba78294 blob + c7eef485c3721f42444509df2a03dc201784624a --- libexec/got-read-pack/got-read-pack.c +++ libexec/got-read-pack/got-read-pack.c @@ -495,7 +495,7 @@ tree_path_changed(int *changed, uint8_t **buf1, size_t */ while (remain1 > 0) { err = got_object_parse_tree_entry(&pte1, &elen, - next_entry1, remain1, idlen); + next_entry1, remain1, idlen, pack->algo); if (err) return err; next_entry1 += elen; @@ -519,7 +519,7 @@ tree_path_changed(int *changed, uint8_t **buf1, size_t while (remain2 > 0) { err = got_object_parse_tree_entry(&pte2, &elen, - next_entry2, remain2, idlen); + next_entry2, remain2, idlen, pack->algo); if (err) return err; next_entry2 += elen; blob - 83d8af428815b7ef730a8ddf19a89a8505a9bd60 blob + 9b5c6b818d19c41eb3e9e4ffede13cd4a6fb81f5 --- libexec/got-read-patch/got-read-patch.c +++ libexec/got-read-patch/got-read-patch.c @@ -55,9 +55,9 @@ #include "got_object.h" #include "got_lib_delta.h" +#include "got_lib_hash.h" #include "got_lib_object.h" #include "got_lib_privsep.h" -#include "got_lib_hash.h" struct imsgbuf ibuf; blob - 39ff4fdaae7bf2fd23444ef6aae255310a4f2ad1 blob + 3a54429e45deb222fd8c58bd8d8d2683a06edd3c --- libexec/got-read-tag/got-read-tag.c +++ libexec/got-read-tag/got-read-tag.c @@ -35,11 +35,11 @@ #include "got_object.h" #include "got_lib_delta.h" +#include "got_lib_hash.h" #include "got_lib_inflate.h" #include "got_lib_object.h" #include "got_lib_object_parse.h" #include "got_lib_privsep.h" -#include "got_lib_hash.h" static volatile sig_atomic_t sigint_received; blob - 500f786f501a74944230154788890612bf220f7c blob + a9cd911be347a80abbe31861aa07381dcd97ccc0 --- libexec/got-read-tree/got-read-tree.c +++ libexec/got-read-tree/got-read-tree.c @@ -36,11 +36,11 @@ #include "got_path.h" #include "got_lib_delta.h" +#include "got_lib_hash.h" #include "got_lib_inflate.h" #include "got_lib_object.h" #include "got_lib_object_parse.h" #include "got_lib_privsep.h" -#include "got_lib_hash.h" static volatile sig_atomic_t sigint_received;