summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2024-10-22 14:30:34 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2024-10-22 14:32:03 +0200
commita5d029ea6474db4f7edf8e9b6d73afd2ae583250 (patch)
tree48fa428961b96c1230fcfef80d187dd365204aa8 /apt-pkg
parentfcccd7fb5ed74ae00c9d675667017d9c84838f69 (diff)
extracttar: Move large buffer to heap for valgrind
valgrind has some trouble on ppc64el with the large buffer, and also on armhf where it seems to not understand the resulting stack clash protector, so let's move it to the heap using simple STL std::array in a std::unique_ptr.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/extracttar.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/apt-pkg/contrib/extracttar.cc b/apt-pkg/contrib/extracttar.cc
index 96cc513f0..dff9326a1 100644
--- a/apt-pkg/contrib/extracttar.cc
+++ b/apt-pkg/contrib/extracttar.cc
@@ -25,9 +25,11 @@
#include <apt-pkg/strutl.h>
#include <algorithm>
+#include <array>
#include <csignal>
#include <cstring>
#include <iostream>
+#include <memory>
#include <string>
#include <fcntl.h>
#include <unistd.h>
@@ -130,6 +132,7 @@ bool ExtractTar::Go(pkgDirStream &Stream)
// Loop over all blocks
string LastLongLink, ItemLink;
string LastLongName, ItemName;
+ auto Junk = std::make_unique<std::array<unsigned char, 32*1024>>();
while (1)
{
bool BadRecord = false;
@@ -290,22 +293,21 @@ bool ExtractTar::Go(pkgDirStream &Stream)
{
// Copy the file over the FD
auto Size = Itm.Size;
- unsigned char Junk[32*1024];
do
{
- auto const Read = std::min<unsigned long long>(Size, sizeof(Junk));
- if (not InFd.Read(Junk, ((Read + (sizeof(Block) - 1)) / sizeof(Block)) * sizeof(Block)))
+ auto const Read = std::min<unsigned long long>(Size, Junk->size());
+ if (not InFd.Read(Junk->data(), ((Read + (sizeof(Block) - 1)) / sizeof(Block)) * sizeof(Block)))
return false;
if (Fd > 0)
{
- if (not FileFd::Write(Fd, Junk, Read))
+ if (not FileFd::Write(Fd, Junk->data(), Read))
return Stream.Fail(Itm, Fd);
}
// An Fd of -2 means to send to a special processing function
else if (Fd == -2)
{
- if (not Stream.Process(Itm, Junk, Read, Itm.Size - Size))
+ if (not Stream.Process(Itm, Junk->data(), Read, Itm.Size - Size))
return Stream.Fail(Itm, Fd);
}