set datasize limit of got-read-pack helpers to maximum
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/lib/object.c b/lib/object.c
index d781faa..f2cc6ae 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -21,6 +21,7 @@
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/syslimits.h>
+#include <sys/resource.h>
#include <errno.h>
#include <fcntl.h>
@@ -228,6 +229,18 @@ request_packed_object(struct got_object **obj, struct got_pack *pack, int idx,
return NULL;
}
+void
+set_max_datasize(void)
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_DATA, &rl) != 0)
+ return;
+
+ rl.rlim_cur = rl.rlim_max;
+ setrlimit(RLIMIT_DATA, &rl);
+}
+
static const struct got_error *
start_pack_privsep_child(struct got_pack *pack, struct got_packidx *packidx)
{
@@ -257,6 +270,7 @@ start_pack_privsep_child(struct got_pack *pack, struct got_packidx *packidx)
err = got_error_from_errno("fork");
goto done;
} else if (pid == 0) {
+ set_max_datasize();
exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_PACK,
pack->path_packfile);
/* not reached */