Commit Diff


commit - 652b2703b30168d3a56716fd7bb2b1a4d9392069
commit + 4842267fac188afbe5e19be24bfce35fc2df19e8
blob - eb92f1cb845b67bd2049d7ca985579894a9c3220
blob + 3a8d465dfe9f909648697939e5bc8b3846ac1fbe
--- lib/object.c
+++ lib/object.c
@@ -184,7 +184,7 @@ parse_object_header(struct got_object **obj, char *buf
 }
 
 static const struct got_error *
-read_object_header(struct got_object **obj, FILE *f)
+read_object_header(struct got_object **obj, int fd)
 {
 	const struct got_error *err;
 	struct got_zstream_buf zb;
@@ -204,7 +204,7 @@ read_object_header(struct got_object **obj, FILE *f)
 	i = 0;
 	totlen = 0;
 	do {
-		err = got_inflate_read(&zb, f, &outlen);
+		err = got_inflate_read_fd(&zb, fd, &outlen);
 		if (err)
 			goto done;
 		if (strchr(zb.outbuf, '\0') == NULL) {
@@ -231,7 +231,6 @@ read_object_header_privsep_child(int obj_fd, int imsg_
 	const struct got_error *err = NULL;
 	struct got_object *obj = NULL;
 	struct imsgbuf ibuf;
-	FILE *f = NULL;
 	int status = 0;
 
 	setproctitle("read object header");
@@ -244,14 +243,7 @@ read_object_header_privsep_child(int obj_fd, int imsg_
 		goto done;
 	}
 
-	f = fdopen(obj_fd, "rb");
-	if (f == NULL) {
-		err = got_error_from_errno();
-		close(obj_fd);
-		goto done;
-	}
-
-	err = read_object_header(&obj, f);
+	err = read_object_header(&obj, obj_fd);
 	if (err)
 		goto done;
 
@@ -263,8 +255,7 @@ done:
 		got_privsep_send_error(&ibuf, err);
 		status = 1;
 	}
-	if (f)
-		fclose(f);
+	close(obj_fd);
 	imsg_clear(&ibuf);
 	close(imsg_fds[1]);
 	_exit(status);