Commit 56bef47ace1a7a76503a86a73aa58d022e7f9006

Stefan Sperling 2018-09-15T20:05:22

fix non-mmap read mode in got-read-pack

diff --git a/libexec/got-read-pack/got-read-pack.c b/libexec/got-read-pack/got-read-pack.c
index 2238e3a..3cb0ac2 100644
--- a/libexec/got-read-pack/got-read-pack.c
+++ b/libexec/got-read-pack/got-read-pack.c
@@ -304,6 +304,10 @@ receive_packidx(struct got_packidx **packidx, struct imsgbuf *ibuf)
 		err = got_error_from_errno();
 		goto done;
 	}
+	if (lseek(p->fd, 0, SEEK_SET) == -1) {
+		err = got_error_from_errno();
+		goto done;
+	}
 
 #ifndef GOT_PACK_NO_MMAP
 	p->map = mmap(NULL, p->len, PROT_READ, MAP_PRIVATE, p->fd, 0);
@@ -366,6 +370,10 @@ receive_pack(struct got_pack **packp, struct imsgbuf *ibuf)
 		err = got_error_from_errno();
 		goto done;
 	}
+	if (lseek(pack->fd, 0, SEEK_SET) == -1) {
+		err = got_error_from_errno();
+		goto done;
+	}
 	pack->path_packfile = strdup(ipack.path_packfile);
 	if (pack->path_packfile == NULL) {
 		err = got_error_from_errno();