]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - io/copy_file_range.c
xfs_io: actually check copy file range helper return values
[thirdparty/xfsprogs-dev.git] / io / copy_file_range.c
index 4e2969c9ca475e7c08914f9c2c8071e2f5e22ac5..d069e5bb905a994e0441083c9214e99dc329edb5 100644 (file)
@@ -120,11 +120,24 @@ copy_range_f(int argc, char **argv)
                return 0;
 
        if (src == 0 && dst == 0 && len == 0) {
-               len = copy_src_filesize(fd);
-               copy_dst_truncate();
+               off64_t sz;
+
+               sz = copy_src_filesize(fd);
+               if (sz < 0 || (unsigned long long)sz > SIZE_MAX) {
+                       ret = 1;
+                       goto out;
+               }
+               len = sz;
+
+               ret = copy_dst_truncate();
+               if (ret < 0) {
+                       ret = 1;
+                       goto out;
+               }
        }
 
        ret = copy_file_range_cmd(fd, &src, &dst, len);
+out:
        close(fd);
        return ret;
 }