Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 618086 - sys-apps/portage-2.3.5: portage_util_file_copy_reflink_linux.c: incorrect lseek offset in plain read/write loop after EINTR
Summary: sys-apps/portage-2.3.5: portage_util_file_copy_reflink_linux.c: incorrect lse...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 635020 619102
  Show dependency tree
 
Reported: 2017-05-10 06:20 UTC by Zac Medico
Modified: 2022-12-26 07:35 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zac Medico gentoo-dev 2017-05-10 06:20:16 UTC
I was reading the code and I noticed that the plain read/write loop can have an incorrect lseek offset after EINTR. This is the fix:

--- a/src/portage_util_file_copy_reflink_linux.c
+++ b/src/portage_util_file_copy_reflink_linux.c
@@ -328,7 +328,7 @@ _reflink_linux_file_copy(PyObject *self, PyObject *args)
                  * correct state, in case an EINTR retry caused it to
                  * get out of sync somewhow.
                  */
-                } else if (lseek(fd_in, offset_out, SEEK_SET) < 0) {
+                } else if (lseek(fd_in, offset_out + buf_bytes, SEEK_SET) < 0) {
                     error = errno;
                 } else {
                     while (1) {
Comment 3 Zac Medico gentoo-dev 2017-08-11 20:36:42 UTC
Fixed in 2.3.6.