From: Omar Polo Subject: got_imsg_raw_delta/req: use struct instead of buffer for ids To: gameoftrees@openbsd.org Date: Tue, 31 Jan 2023 17:29:35 +0100 like the previous, should be a no-op. passes regress with GOT_TEST_PACK=1. P.S.: if someone is bored and grep doesn't lie, got_object_read_raw_delta() is currently unused. diff refs/heads/main refs/heads/x commit - 265df21f29865b8cc1eb0f0b93b8ca91ff134414 commit + 7064a22e5313954a54de57b35d24f5e4f6c54959 blob - a0f34aa4a82baaa0867ea1ea1ae0e1c7cbbd20bf blob + cce4cea87c0a4dcf12328d3491728a50bcce8f84 --- lib/got_lib_privsep.h +++ lib/got_lib_privsep.h @@ -304,7 +304,7 @@ struct got_imsg_raw_delta { /* Structure for GOT_IMSG_RAW_DELTA. */ struct got_imsg_raw_delta { - uint8_t base_id[SHA1_DIGEST_LENGTH]; + struct got_object_id base_id; uint64_t base_size; uint64_t result_size; off_t delta_size; @@ -546,7 +546,7 @@ struct got_imsg_raw_delta_request { * Structure for GOT_IMSG_RAW_DELTA_REQUEST data. */ struct got_imsg_raw_delta_request { - uint8_t id[SHA1_DIGEST_LENGTH]; + struct got_object_id id; int idx; }; blob - 8b8219e58dcd172645c354edfcb985499bd7faa6 blob + 48bdc5abc37116465cd5276b7720b4809ef3079c --- lib/privsep.c +++ lib/privsep.c @@ -2954,7 +2954,7 @@ got_privsep_send_raw_delta_req(struct imsgbuf *ibuf, i memset(&dreq, 0, sizeof(dreq)); dreq.idx = idx; - memcpy(dreq.id, id->sha1, SHA1_DIGEST_LENGTH); + memcpy(&dreq.id, id, sizeof(dreq.id)); if (imsg_compose(ibuf, GOT_IMSG_RAW_DELTA_REQUEST, 0, 0, -1, &dreq, sizeof(dreq)) == -1) @@ -2984,7 +2984,7 @@ got_privsep_send_raw_delta(struct imsgbuf *ibuf, uint6 idelta.delta_compressed_size = delta_compressed_size; idelta.delta_offset = delta_offset; idelta.delta_out_offset = delta_out_offset; - memcpy(idelta.base_id, base_id->sha1, SHA1_DIGEST_LENGTH); + memcpy(&idelta.base_id, &base_id, sizeof(idelta.base_id)); ret = imsg_compose(ibuf, GOT_IMSG_RAW_DELTA, 0, 0, -1, &idelta, sizeof(idelta)); @@ -2997,7 +2997,8 @@ got_privsep_recv_raw_delta(uint64_t *base_size, uint64 const struct got_error * got_privsep_recv_raw_delta(uint64_t *base_size, uint64_t *result_size, off_t *delta_size, off_t *delta_compressed_size, off_t *delta_offset, - off_t *delta_out_offset, struct got_object_id **base_id, struct imsgbuf *ibuf) + off_t *delta_out_offset, struct got_object_id **base_id, + struct imsgbuf *ibuf) { const struct got_error *err = NULL; struct imsg imsg; @@ -3036,7 +3037,7 @@ got_privsep_recv_raw_delta(uint64_t *base_size, uint64 err = got_error_from_errno("malloc"); break; } - memcpy((*base_id)->sha1, delta->base_id, SHA1_DIGEST_LENGTH); + memcpy(*base_id, &delta->base_id, sizeof(**base_id)); break; default: err = got_error(GOT_ERR_PRIVSEP_MSG); blob - 7da00ecab5dd244314979ca026eb0743fa4b139b blob + d3624830234626794cb116fcaee59a11d7cac75b --- libexec/got-read-pack/got-read-pack.c +++ libexec/got-read-pack/got-read-pack.c @@ -880,7 +880,7 @@ raw_delta_request(struct imsg *imsg, struct imsgbuf *i if (datalen != sizeof(req)) return got_error(GOT_ERR_PRIVSEP_LEN); memcpy(&req, imsg->data, sizeof(req)); - memcpy(id.sha1, req.id, SHA1_DIGEST_LENGTH); + memcpy(&id, &req.id, sizeof(id)); imsg->fd = -1;