mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 22:40:16 +01: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
This commit is contained in:
parent
f2dbf8fbc0
commit
70ebdc7730
1 changed files with 3 additions and 3 deletions
|
|
@ -2700,7 +2700,7 @@ copy_lease (const char *src, const char *dst)
|
|||
{
|
||||
nm_auto_close int src_fd = -1;
|
||||
int dst_fd;
|
||||
ssize_t res;
|
||||
ssize_t res, size = SSIZE_MAX;
|
||||
|
||||
src_fd = open (src, O_RDONLY|O_CLOEXEC);
|
||||
if (src_fd < 0)
|
||||
|
|
@ -2710,8 +2710,8 @@ copy_lease (const char *src, const char *dst)
|
|||
if (dst_fd < 0)
|
||||
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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue