]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Merge branch 'maint' into next
authorTheodore Ts'o <tytso@mit.edu>
Tue, 22 Aug 2017 16:19:30 +0000 (12:19 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 22 Aug 2017 16:19:30 +0000 (12:19 -0400)
1  2 
lib/ext2fs/unix_io.c

diff --combined lib/ext2fs/unix_io.c
index dc2a2e9fea0bf4e83057c6d615a783599c6da458,64141954e6a57ea88d73488054199d774a8a5bc8..98a6756f4ae3034430649710d7c673f919a560dd
@@@ -185,6 -185,7 +185,7 @@@ static errcode_t raw_read_blk(io_channe
                actual = pread64(data->dev, buf, size, location);
                if (actual == size)
                        return 0;
+               actual = 0;
        }
  #elif HAVE_PREAD
        /* Try an aligned pread */
                actual = pread(data->dev, buf, size, location);
                if (actual == size)
                        return 0;
+               actual = 0;
        }
  #endif /* HAVE_PREAD */
  
@@@ -247,7 -249,8 +249,8 @@@ bounce_read
        return 0;
  
  error_out:
-       memset((char *) buf+actual, 0, size-actual);
+       if (actual >= 0 && actual < size)
+               memset((char *) buf+actual, 0, size-actual);
        if (channel->read_error)
                retval = (channel->read_error)(channel, block, count, buf,
                                               size, actual, retval);
@@@ -718,7 -721,6 +721,7 @@@ static errcode_t unixfd_open(const cha
        int fd_flags;
  
        fd = atoi(str_fd);
 +#if defined(HAVE_FCNTL)
        fd_flags = fcntl(fd, F_GETFD);
        if (fd_flags == -1)
                return -EBADF;
        if (fd_flags & O_DIRECT)
                flags |= IO_FLAG_DIRECT_IO;
  #endif
 +#endif  /* HAVE_FCNTL */
  
        return unix_open_channel(str_fd, fd, flags, channel, unixfd_io_manager);
  }
@@@ -1032,10 -1033,8 +1035,10 @@@ static errcode_t unix_flush(io_channel 
  #ifndef NO_IO_CACHE
        retval = flush_cached_blocks(channel, data, 0);
  #endif
 +#ifdef HAVE_FSYNC
        if (!retval && fsync(data->dev) != 0)
                return errno;
 +#endif
        return retval;
  }