diff options
author | Pino Toscano <pino@debian.org> | 2015-12-19 12:06:53 +0100 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2015-12-19 12:52:45 +0100 |
commit | c0b271edc2f6d9e5dea5ac82fbc911f0e3adfa7a (patch) | |
tree | 72ed60fb4f13f1d4c533d79dd7faf902a36f36e9 /apt-pkg | |
parent | 0c93e388d417ab03f2857903bb5791f4312cdbd0 (diff) |
CopyFile: avoid failing on EOF on some systems
On EOF, ToRead will be 0, which might trigger on some systems (e.g.
on the Hurd) an error due to the invalid byte count passed to write().
The whole loop already checks for ToRead != 0, so perform the writing
step only when there was actual data read.
Closes: #808381
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 86ca82cff..1ffa407bc 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -165,7 +165,7 @@ bool CopyFile(FileFd &From,FileFd &To) unsigned long long ToRead = 0; do { if (From.Read(Buf.get(),BufSize, &ToRead) == false || - To.Write(Buf.get(),ToRead) == false) + (ToRead > 0 && To.Write(Buf.get(),ToRead) == false)) return false; } while (ToRead != 0); |