summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPino Toscano <pino@debian.org>2015-12-19 12:00:43 +0100
committerJulian Andres Klode <jak@debian.org>2015-12-19 12:52:04 +0100
commit0c93e388d417ab03f2857903bb5791f4312cdbd0 (patch)
tree945b9720fc549c0fc6f4390a55116f9aafde7ef3
parentdbbe1e6393dab381db0f48b2a645babdddb14eca (diff)
CopyFile: fix BufSize to a sane value
Commit e977b8b9234ac5db32f2f0ad7e183139b988340d tries to make BufSize calculated based on the size of the buffer; the problem is that std::unique_ptr::size() returns a pointer to the data, so sizeof() equals to the size of a pointer (later divided by sizeof(char), which is 1). The result is that the CopyFile copies in chunks of 8 bytes, which is not exactly ideal... As solution, declare BufSize in advance, and use its value to allocate the Buf array. Closes: #808381
-rw-r--r--apt-pkg/contrib/fileutl.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 014f0ee51..86ca82cff 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -160,8 +160,8 @@ bool CopyFile(FileFd &From,FileFd &To)
return false;
// Buffered copy between fds
- std::unique_ptr<unsigned char[]> Buf(new unsigned char[64000]);
- constexpr unsigned long long BufSize = sizeof(Buf.get())/sizeof(Buf.get()[0]);
+ constexpr size_t BufSize = 64000;
+ std::unique_ptr<unsigned char[]> Buf(new unsigned char[BufSize]);
unsigned long long ToRead = 0;
do {
if (From.Read(Buf.get(),BufSize, &ToRead) == false ||