Commit 6c77e0337609d941281f017b3e0229ae45a35b7a

Omar Polo 2022-07-02T21:21:52

fix imsg_add TREE_ENTRY: Result too large on i386 There's a math error when computing the size of one entries in the batching code. Reported by semarie, ok semarie stsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/lib/privsep.c b/lib/privsep.c
index c0bdac7..5655e96 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -1471,7 +1471,8 @@ send_tree_entries(struct imsgbuf *ibuf, struct got_parsed_tree_entry *entries,
 	i = 0;
 	for (j = 0; j < nentries; j++) {
 		struct got_parsed_tree_entry *pte = &entries[j];
-		size_t len = sizeof(*pte) + pte->namelen;
+		size_t len = SHA1_DIGEST_LENGTH + sizeof(pte->mode) +
+		    sizeof(pte->namelen) + pte->namelen;
 
 		if (j > 0 &&
 		    entries_len + len > MAX_IMSGSIZE - IMSG_HEADER_SIZE) {