Commit e5ad73651d7663bfc6ca5d6f3ec622c5f59413bf

Stefan Sperling 2021-05-20T09:51:59

fix file descriptor leak when got-read-object returns a raw object

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/libexec/got-read-object/got-read-object.c b/libexec/got-read-object/got-read-object.c
index 1d8cea7..e11b7d2 100644
--- a/libexec/got-read-object/got-read-object.c
+++ b/libexec/got-read-object/got-read-object.c
@@ -191,6 +191,8 @@ main(int argc, char *argv[])
 			}
 			err = send_raw_obj(&ibuf, obj, imsg.fd, imsg_outfd.fd);
 			imsg.fd = -1; /* imsg.fd is owned by send_raw_obj() */
+			if (close(imsg_outfd.fd) == -1 && err == NULL)
+				err = got_error_from_errno("close");
 			imsg_free(&imsg_outfd);
 			if (err)
 				goto done;