Commit Diff


commit - c5b519a9a281ccd2b4787f4409e7431fc66f92bc
commit + 35cdfa2c870e6a3e81defeece73b69570753a845
blob - a60de9933f308e755f32d20abbdc344e4f1ffd6c
blob + eb6769ef2d4ba39ff599e3c075d2618ee4890387
--- lib/got_lib_privsep.h
+++ lib/got_lib_privsep.h
@@ -344,7 +344,7 @@ struct got_imsg_reused_deltas {
 
 /* Structure for GOT_IMSG_COMMIT_PAINTING_REQUEST. */
 struct got_imsg_commit_painting_request {
-	uint8_t id[SHA1_DIGEST_LENGTH];
+	struct got_object_id id;
 	int idx;
 	int color;
 } __attribute__((__packed__));
@@ -365,7 +365,7 @@ struct got_imsg_painted_commits {
 
 /* Structure for GOT_IMSG_TAG data. */
 struct got_imsg_tag_object {
-	uint8_t id[SHA1_DIGEST_LENGTH];
+	struct got_object_id id;
 	int obj_type;
 	size_t tag_len;
 	size_t tagger_len;
@@ -585,7 +585,7 @@ struct got_imsg_commit_traversal_request {
 /* Structure for GOT_IMSG_TRAVERSED_COMMITS  */
 struct got_imsg_traversed_commits {
 	size_t ncommits;
-	/* Followed by ncommit IDs of SHA1_DIGEST_LENGTH each */
+	/* Followed by ncommit struct got_object_id */
 } __attribute__((__packed__));
 
 /* Structure for GOT_IMSG_ENUMERATED_COMMIT  */
blob - 8b00d871a944e99cb7f747a1e8e7a752f11e38fd
blob + a5915a12dc677151a95503eaef04dc123e890fb4
--- lib/privsep.c
+++ lib/privsep.c
@@ -1793,7 +1793,7 @@ got_privsep_send_tag(struct imsgbuf *ibuf, struct got_
 		return got_error_from_errno("malloc");
 
 	itag = (struct got_imsg_tag_object *)buf;
-	memcpy(itag->id, tag->id.sha1, sizeof(itag->id));
+	memcpy(&itag->id, &tag->id, sizeof(itag->id));
 	itag->obj_type = tag->obj_type;
 	itag->tag_len = tag_len;
 	itag->tagger_len = tagger_len;
@@ -1864,7 +1864,7 @@ got_privsep_recv_tag(struct got_tag_object **tag, stru
 			break;
 		}
 
-		memcpy((*tag)->id.sha1, itag->id, SHA1_DIGEST_LENGTH);
+		memcpy(&(*tag)->id, &itag->id, sizeof(itag->id));
 
 		(*tag)->tag = strndup(imsg.data + len, itag->tag_len);
 		if ((*tag)->tag == NULL) {
@@ -2680,6 +2680,7 @@ got_privsep_recv_traversed_commits(struct got_commit_o
 	const struct got_error *err = NULL;
 	struct imsg imsg;
 	struct got_imsg_traversed_commits *icommits;
+	struct got_object_id *ids;
 	size_t datalen;
 	int i, done = 0;
 
@@ -2696,18 +2697,18 @@ got_privsep_recv_traversed_commits(struct got_commit_o
 		case GOT_IMSG_TRAVERSED_COMMITS:
 			icommits = imsg.data;
 			if (datalen != sizeof(*icommits) +
-			    icommits->ncommits * SHA1_DIGEST_LENGTH) {
+			    icommits->ncommits * sizeof(*ids)) {
 				err = got_error(GOT_ERR_PRIVSEP_LEN);
 				break;
 			}
+			ids = imsg.data + sizeof(*icommits);
 			for (i = 0; i < icommits->ncommits; i++) {
 				struct got_object_qid *qid;
-				uint8_t *sha1 = (uint8_t *)imsg.data +
-				    sizeof(*icommits) + i * SHA1_DIGEST_LENGTH;
+
 				err = got_object_qid_alloc_partial(&qid);
 				if (err)
 					break;
-				memcpy(qid->id.sha1, sha1, SHA1_DIGEST_LENGTH);
+				memcpy(&qid->id, &ids[i], sizeof(ids[i]));
 				STAILQ_INSERT_TAIL(commit_ids, qid, entry);
 
 				/* The last commit may contain a change. */
@@ -3381,7 +3382,7 @@ got_privsep_send_painting_request(struct imsgbuf *ibuf
 	struct got_imsg_commit_painting_request ireq;
 
 	memset(&ireq, 0, sizeof(ireq));
-	memcpy(ireq.id, id->sha1, sizeof(ireq.id));
+	memcpy(&ireq.id, id, sizeof(ireq.id));
 	ireq.idx = idx;
 	ireq.color = color;
 
blob - 265520e5c67f452d52101dc8114d3b4b989d8ba1
blob + f62b5b34419a28d58f8666b7c7f128f4fdde0513
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
@@ -564,7 +564,7 @@ send_traversed_commits(struct got_object_id *commit_id
 
 	wbuf = imsg_create(ibuf, GOT_IMSG_TRAVERSED_COMMITS, 0, 0,
 	    sizeof(struct got_imsg_traversed_commits) +
-	    ncommits * SHA1_DIGEST_LENGTH);
+	    ncommits * sizeof(commit_ids[0]));
 	if (wbuf == NULL)
 		return got_error_from_errno("imsg_create TRAVERSED_COMMITS");
 
@@ -573,7 +573,7 @@ send_traversed_commits(struct got_object_id *commit_id
 
 	for (i = 0; i < ncommits; i++) {
 		struct got_object_id *id = &commit_ids[i];
-		if (imsg_add(wbuf, id->sha1, SHA1_DIGEST_LENGTH) == -1) {
+		if (imsg_add(wbuf, id, sizeof(*id)) == -1) {
 			return got_error_from_errno(
 			    "imsg_add TRAVERSED_COMMITS");
 		}
@@ -658,7 +658,7 @@ commit_traversal_request(struct imsg *imsg, struct ims
 		}
 
 		if (sizeof(struct got_imsg_traversed_commits) +
-		    ncommits * SHA1_DIGEST_LENGTH >= max_datalen) {
+		    ncommits * sizeof(commit_ids[0]) >= max_datalen) {
 			err = send_traversed_commits(commit_ids, ncommits,
 			    ibuf);
 			if (err)
@@ -1193,7 +1193,7 @@ enumerate_tree(int *have_all_entries, struct imsgbuf *
 	err = got_object_qid_alloc_partial(&qid);
 	if (err)
 		return err;
-	memcpy(&qid->id.sha1, tree_id, SHA1_DIGEST_LENGTH);
+	memcpy(&qid->id, tree_id, sizeof(*tree_id));
 	qid->data = strdup(path);
 	if (qid->data == NULL) {
 		err = got_error_from_errno("strdup");
@@ -1797,7 +1797,7 @@ commit_painting_request(struct imsg *imsg, struct imsg
 	if (datalen != sizeof(ireq))
 		return got_error(GOT_ERR_PRIVSEP_LEN);
 	memcpy(&ireq, imsg->data, sizeof(ireq));
-	memcpy(id.sha1, ireq.id, SHA1_DIGEST_LENGTH);
+	memcpy(&id, &ireq.id, sizeof(id));
 
 	err = queue_commit_id(&ids, &id, ireq.color);
 	if (err)