commit c26ee7add64b80ff74fa5d22df886393a52f9b41 from: Omar Polo via: Thomas Adam date: Thu Jun 23 14:09:35 2022 UTC memset all stack-allocated structs used to send messages; ok stsp@ commit - 1bb2bba217ad222aed1d79baf9d8025110130bd3 commit + c26ee7add64b80ff74fa5d22df886393a52f9b41 blob - b28458e490517b2cfd9cbb4920208ef0f109182e blob + ececeecbfe2204f148096c913a860427197e878a --- lib/privsep.c +++ lib/privsep.c @@ -296,6 +296,7 @@ got_privsep_send_raw_obj(struct imsgbuf *ibuf, off_t s size_t len = sizeof(iobj); struct ibuf *wbuf; + memset(&iobj, 0, sizeof(iobj)); iobj.hdrlen = hdrlen; iobj.size = size; @@ -386,6 +387,7 @@ got_privsep_send_commit_req(struct imsgbuf *ibuf, int void *data; size_t len; + memset(&iobj, 0, sizeof(iobj)); if (pack_idx != -1) { /* commit is packed */ iobj.idx = pack_idx; memcpy(iobj.id, id->sha1, sizeof(iobj.id)); @@ -444,6 +446,7 @@ got_privsep_send_tag_req(struct imsgbuf *ibuf, int fd, void *data; size_t len; + memset(&iobj, 0, sizeof(iobj)); if (pack_idx != -1) { /* tag is packed */ iobj.idx = pack_idx; memcpy(iobj.id, id->sha1, sizeof(iobj.id)); @@ -470,6 +473,7 @@ got_privsep_send_blob_req(struct imsgbuf *ibuf, int in void *data; size_t len; + memset(&iobj, 0, sizeof(iobj)); if (pack_idx != -1) { /* blob is packed */ iobj.idx = pack_idx; memcpy(iobj.id, id->sha1, sizeof(iobj.id)); @@ -1422,6 +1426,8 @@ send_tree_entries_batch(struct imsgbuf *ibuf, struct got_imsg_tree_entries ientries; int i; + memset(&ientries, 0, sizeof(ientries)); + wbuf = imsg_create(ibuf, GOT_IMSG_TREE_ENTRIES, 0, 0, len); if (wbuf == NULL) return got_error_from_errno("imsg_create TREE_ENTRY"); @@ -1494,6 +1500,7 @@ got_privsep_send_tree(struct imsgbuf *ibuf, const struct got_error *err = NULL; struct got_imsg_tree_object itree; + memset(&itree, 0, sizeof(itree)); itree.nentries = nentries; if (imsg_compose(ibuf, GOT_IMSG_TREE, 0, 0, -1, &itree, sizeof(itree)) == -1) @@ -1684,6 +1691,7 @@ got_privsep_send_blob(struct imsgbuf *ibuf, size_t siz { struct got_imsg_blob iblob; + memset(&iblob, 0, sizeof(iblob)); iblob.size = size; iblob.hdrlen = hdrlen; @@ -1963,6 +1971,9 @@ got_privsep_init_pack_child(struct imsgbuf *ibuf, stru struct got_imsg_pack ipack; int fd; + memset(&ipackidx, 0, sizeof(ipackidx)); + memset(&ipack, 0, sizeof(ipack)); + ipackidx.len = packidx->len; ipackidx.packfile_size = pack->filesize; fd = dup(packidx->fd); @@ -2001,6 +2012,7 @@ got_privsep_send_packed_obj_req(struct imsgbuf *ibuf, { struct got_imsg_packed_object iobj; + memset(&iobj, 0, sizeof(iobj)); iobj.idx = idx; memcpy(iobj.id, id->sha1, sizeof(iobj.id)); @@ -2018,6 +2030,7 @@ got_privsep_send_packed_raw_obj_req(struct imsgbuf *ib { struct got_imsg_packed_object iobj; + memset(&iobj, 0, sizeof(iobj)); iobj.idx = idx; memcpy(iobj.id, id->sha1, sizeof(iobj.id)); @@ -2982,6 +2995,7 @@ got_privsep_send_raw_delta_req(struct imsgbuf *ibuf, i { struct got_imsg_raw_delta_request dreq; + memset(&dreq, 0, sizeof(dreq)); dreq.idx = idx; memcpy(dreq.id, id->sha1, SHA1_DIGEST_LENGTH); @@ -3006,6 +3020,7 @@ got_privsep_send_raw_delta(struct imsgbuf *ibuf, uint6 struct got_imsg_raw_delta idelta; int ret; + memset(&idelta, 0, sizeof(idelta)); idelta.base_size = base_size; idelta.result_size = result_size; idelta.delta_size = delta_size; @@ -3088,6 +3103,8 @@ send_idlist(struct imsgbuf *ibuf, struct got_object_id struct ibuf *wbuf; size_t i; + memset(&idlist, 0, sizeof(idlist)); + if (nids > GOT_IMSG_OBJ_ID_LIST_MAX_NIDS) return got_error(GOT_ERR_NO_SPACE); @@ -3223,6 +3240,8 @@ got_privsep_send_reused_deltas(struct imsgbuf *ibuf, struct got_imsg_reused_deltas ideltas; size_t i; + memset(&ideltas, 0, sizeof(ideltas)); + if (ndeltas > GOT_IMSG_REUSED_DELTAS_MAX_NDELTAS) return got_error(GOT_ERR_NO_SPACE);