crash-pipe: Fix write the coredump to the file 37/180537/1 accepted/tizen/unified/20180614.150754 submit/tizen/20180613.110142
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Wed, 30 May 2018 11:33:20 +0000 (13:33 +0200)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Wed, 30 May 2018 12:00:37 +0000 (14:00 +0200)
splice returns EINVAL if (loff_t)(len + out.pos) is negative number.
This was the case on aarch64 and x86_64.

Change-Id: Ic52d08efce3fca555a83319c8161c3656b553cc1

src/crash-pipe/crash-pipe.c

index 1ba2f3a..53c0ac0 100644 (file)
@@ -74,10 +74,14 @@ static int copy_fd_splice(int in, int out)
        ssize_t s;
        _Bool copied_data = 0;
 
-       const ssize_t max_splice = SSIZE_MAX;
+       ssize_t max_splice = SSIZE_MAX;
 
        do {
                s = splice(in, NULL, out, NULL, max_splice, SPLICE_F_MOVE);
+               // output file position + len must not exceed the loff_t type limit,
+               // that's why we reduce len in every iteration
+               max_splice -= s;
+
                // We can try to fallback to simple copy only if first splice failed
                // (ie. we have not consumed any data yet)
                if (!copied_data && s > 0)