commit 7841c0d12f0a0e3f73db772df3b177a99ac0771f from: Omar Polo date: Wed Feb 01 16:40:54 2023 UTC got_imsg_object: use struct instead of buffer for id ok stsp@ commit - 39958d0b3edc8d5f522b8263cf8aa2cb1aa64020 commit + 7841c0d12f0a0e3f73db772df3b177a99ac0771f blob - 151e0d73fa443289c8609863654c6bef6d128723 blob + 2817ac884ce25ec43a9812d10cca3e9dc017a4cf --- lib/got_lib_privsep.h +++ lib/got_lib_privsep.h @@ -220,7 +220,7 @@ struct got_imsg_error { * Structure for GOT_IMSG_TREE_REQUEST and GOT_IMSG_OBJECT data. */ struct got_imsg_object { - uint8_t id[SHA1_DIGEST_LENGTH]; + struct got_object_id id; /* These fields are the same as in struct got_object. */ int type; blob - 970978560467422ed3a634b6c3b86e48e6b49fd0 blob + 1f118154617c4dae7a5a12d5531b577d6d906da7 --- lib/privsep.c +++ lib/privsep.c @@ -398,7 +398,7 @@ got_privsep_send_tree_req(struct imsgbuf *ibuf, int fd if (wbuf == NULL) return got_error_from_errno("imsg_create TREE_REQUEST"); - 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 TREE_REQUEST"); if (pack_idx != -1) { /* tree is packed */ @@ -510,7 +510,7 @@ got_privsep_send_obj(struct imsgbuf *ibuf, struct got_ memset(&iobj, 0, sizeof(iobj)); - memcpy(iobj.id, obj->id.sha1, sizeof(iobj.id)); + memcpy(&iobj.id, &obj->id, sizeof(iobj.id)); iobj.type = obj->type; iobj.flags = obj->flags; iobj.hdrlen = obj->hdrlen; @@ -1118,7 +1118,7 @@ got_privsep_get_imsg_obj(struct got_object **obj, stru if (*obj == NULL) return got_error_from_errno("calloc"); - memcpy((*obj)->id.sha1, iobj->id, SHA1_DIGEST_LENGTH); + memcpy(&(*obj)->id, &iobj->id, sizeof(iobj->id)); (*obj)->type = iobj->type; (*obj)->flags = iobj->flags; (*obj)->hdrlen = iobj->hdrlen;