- n = loop_read(STDIN_FILENO, p + 9, COREDUMP_MAX, false);
- if (n < 0) {
- log_error("Failed to read core dump data: %s", strerror(-n));
- r = (int) n;
- goto finish;
+ for (;;) {
+ n = loop_read(STDIN_FILENO, coredump_data + coredump_size,
+ coredump_bufsize - coredump_size, false);
+ if (n < 0) {
+ log_error("Failed to read core data: %s", strerror(-n));
+ r = (int) n;
+ goto finish;
+ } else if (n == 0)
+ break;
+
+ coredump_size += n;
+
+ if (coredump_size > COREDUMP_MAX) {
+ log_error("Core too large, core will not be stored.");
+ goto finalize;
+ }
+
+ if (!GREEDY_REALLOC(coredump_data, coredump_bufsize, coredump_size + 1)) {
+ log_warning("Failed to allocate memory for core, core will not be stored.");
+ goto finalize;
+ }