Index: source/Host/common/File.cpp =================================================================== --- source/Host/common/File.cpp +++ source/Host/common/File.cpp @@ -771,21 +771,34 @@ int fd = GetDescriptor(); if (fd != kInvalidDescriptor) { - ssize_t bytes_read = -1; - do + size_t bytes_left = num_bytes; + num_bytes = 0; + char *pos = (char*)buf; + while (bytes_left > 0) { - bytes_read = ::pread (fd, buf, num_bytes, offset); - } while (bytes_read < 0 && errno == EINTR); + ssize_t bytes_read = -1; + do + { + bytes_read = ::pread (fd, pos, bytes_left, offset); + } while (bytes_read < 0 && errno == EINTR); - if (bytes_read < 0) - { - num_bytes = 0; - error.SetErrorToErrno(); - } - else - { - offset += bytes_read; - num_bytes = bytes_read; + if (bytes_read < 0) + { + num_bytes = 0; + error.SetErrorToErrno(); + break; + } + else if (bytes_read == 0) + { + break; + } + else + { + offset += bytes_read; + num_bytes += bytes_read; + bytes_left -= bytes_read; + pos += bytes_read; + } } } else