mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 12:34:55 +00:00
nm-manager: restore passing correct size to sendfile in copy_lease()
Otherwise sendfile() fails with EINVAL when the file offset is greater than zero (pos + size > max), always on the second iteration. Fixes:0c6cd07ec8
('nm-manager: remove lease file if copying dhclient lease fails') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/359 (cherry picked from commit70ebdc7730
)
This commit is contained in:
parent
61d431a9e8
commit
c95bdb21a7
|
@ -2700,7 +2700,7 @@ copy_lease (const char *src, const char *dst)
|
||||||
{
|
{
|
||||||
nm_auto_close int src_fd = -1;
|
nm_auto_close int src_fd = -1;
|
||||||
int dst_fd;
|
int dst_fd;
|
||||||
ssize_t res;
|
ssize_t res, size = SSIZE_MAX;
|
||||||
|
|
||||||
src_fd = open (src, O_RDONLY|O_CLOEXEC);
|
src_fd = open (src, O_RDONLY|O_CLOEXEC);
|
||||||
if (src_fd < 0)
|
if (src_fd < 0)
|
||||||
|
@ -2710,8 +2710,8 @@ copy_lease (const char *src, const char *dst)
|
||||||
if (dst_fd < 0)
|
if (dst_fd < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
while ((res = sendfile (dst_fd, src_fd, NULL, G_MAXSSIZE)) > 0) {
|
while ((res = sendfile (dst_fd, src_fd, NULL, size)) > 0)
|
||||||
}
|
size -= res;
|
||||||
|
|
||||||
nm_close (dst_fd);
|
nm_close (dst_fd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue