From a5d029ea6474db4f7edf8e9b6d73afd2ae583250 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 22 Oct 2024 14:30:34 +0200 Subject: 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. --- apt-pkg/contrib/extracttar.cc | 12 +++++++----- 1 file 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 #include +#include #include #include #include +#include #include #include #include @@ -130,6 +132,7 @@ bool ExtractTar::Go(pkgDirStream &Stream) // Loop over all blocks string LastLongLink, ItemLink; string LastLongName, ItemName; + auto Junk = std::make_unique>(); 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(Size, sizeof(Junk)); - if (not InFd.Read(Junk, ((Read + (sizeof(Block) - 1)) / sizeof(Block)) * sizeof(Block))) + auto const Read = std::min(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); } -- cgit v1.2.3-70-g09d2