commit 0f23036a1e7b488206af69d68173c2654d9add80 from: Omar Polo via: Thomas Adam date: Fri Feb 03 15:22:14 2023 UTC got_imsg_send_remote_ref: use struct instead of buffer for id ok stsp@ commit - ea58e974280c920fa9d7ed103f89fddcaa68e867 commit + 0f23036a1e7b488206af69d68173c2654d9add80 blob - c2ad56a30ba18becd4e2ae92ae09c83fd8c44023 blob + 8e8fa8cd52baa65aa76c0a56a4df206a5c0906b5 --- lib/got_lib_privsep.h +++ lib/got_lib_privsep.h @@ -466,7 +466,7 @@ struct got_imsg_send_ref { /* Structure for GOT_IMSG_SEND_REMOTE_REF data. */ struct got_imsg_send_remote_ref { - uint8_t id[SHA1_DIGEST_LENGTH]; + struct got_object_id id; size_t name_len; /* Followed by name_len data bytes. */ } __attribute__((__packed__)); blob - 4f6cbbc3914a6fd6cc794cb8f781bce3e2a8ecbd blob + 5490b22f536975ef6009f10e8c9939072b0580f3 --- lib/privsep.c +++ lib/privsep.c @@ -918,7 +918,7 @@ got_privsep_recv_send_remote_refs(struct got_pathlist_ err = got_error_from_errno("malloc"); goto done; } - memcpy(id->sha1, iremote_ref.id, SHA1_DIGEST_LENGTH); + memcpy(id, &iremote_ref.id, sizeof(*id)); refname = strndup(imsg.data + sizeof(iremote_ref), datalen - sizeof(iremote_ref)); if (refname == NULL) { blob - bec38f299d9e1f8d432810a730ea140117bc039b blob + a98746344cc5f8e8e258cde72dee8d66b9c1e846 --- libexec/got-send-pack/got-send-pack.c +++ libexec/got-send-pack/got-send-pack.c @@ -204,7 +204,7 @@ send_their_ref(struct imsgbuf *ibuf, struct got_object return got_error_from_errno("imsg_create SEND_REMOTE_REF"); /* Keep in sync with struct got_imsg_send_remote_ref definition! */ - if (imsg_add(wbuf, refid->sha1, SHA1_DIGEST_LENGTH) == -1) + if (imsg_add(wbuf, refid, sizeof(*refid)) == -1) return got_error_from_errno("imsg_add SEND_REMOTE_REF"); if (imsg_add(wbuf, &reflen, sizeof(reflen)) == -1) return got_error_from_errno("imsg_add SEND_REMOTE_REF");