fcopyfile() reads 1 MiB of data every time but when a fragment smaller
than 1 MiB is left, it still reads 1 MiB of data, causing to never meet
the condition of "off == size". This leads to an infinity loop which
continues to write until CephFS becomes full.
Resolves: rhbz#
2379716
Fixes: https://tracker.ceph.com/issues/72238
Signed-off-by: Rishabh Dave <ridave@redhat.com>
if (r < 0) {
ldout(cct, 10) << "fcopyfile: error reading copy data, r=" << r << dendl;
goto out;
- }
+ } else {
+ len = r;
+ }
r = write(dest, in_buf, len, off);
if (r < 0) {
}
off = off + len;
- if (off == size)
+ if (off == size) {
break;
+ } else if (off > size) {
+ ldout(cct, 0) << __FILE__ << ", " << __func__ << "() at " << __LINE__
+ << " internal error: \"off\" is greater than \"size\"; "
+ " off = " << off << " size = " << size << dendl;
+ r = -1;
+ goto out;
+ }
}
}
out: