summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/md5.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-07-30 15:31:39 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2009-07-30 15:31:39 +0200
commit57722714255118560c98b3245413ff5f693b993c (patch)
tree48f4e1c25d7fd07bdbec6e7effa792739c157402 /apt-pkg/contrib/md5.cc
parent8dfb8a0ab2c2a06e319678701c144e5156d7e869 (diff)
parentd5752e18bed18c706c93f5c43c61016c72132ede (diff)
merged from debian-sid
Diffstat (limited to 'apt-pkg/contrib/md5.cc')
-rw-r--r--apt-pkg/contrib/md5.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/apt-pkg/contrib/md5.cc b/apt-pkg/contrib/md5.cc
index a095f8f0f..2bfd70f1b 100644
--- a/apt-pkg/contrib/md5.cc
+++ b/apt-pkg/contrib/md5.cc
@@ -294,11 +294,16 @@ bool MD5Summation::AddFD(int Fd,unsigned long Size)
{
unsigned char Buf[64*64];
int Res = 0;
- while (Size != 0)
+ int ToEOF = (Size == 0);
+ while (Size != 0 || ToEOF)
{
- Res = read(Fd,Buf,min(Size,(unsigned long)sizeof(Buf)));
- if (Res < 0 || (unsigned)Res != min(Size,(unsigned long)sizeof(Buf)))
- return false;
+ unsigned n = sizeof(Buf);
+ if (!ToEOF) n = min(Size,(unsigned long)n);
+ Res = read(Fd,Buf,n);
+ if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
+ return false;
+ if (ToEOF && Res == 0) // EOF
+ break;
Size -= Res;
Add(Buf,Res);
}