diff options
| author | Julian Andres Klode <jak@debian.org> | 2024-10-22 16:45:59 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2024-10-22 16:45:59 +0000 |
| commit | fe1d99dc4494a162dc3e3b8738441d9f0b061949 (patch) | |
| tree | 584705b57f4e923f363effc915135805890156b3 | |
| parent | 3ebde0463a3c8a82bc5a10c5d85e95f3a7116ef8 (diff) | |
| parent | a5d029ea6474db4f7edf8e9b6d73afd2ae583250 (diff) | |
Merge branch 'main' into 'main'
extracttar: Move large buffer to heap for valgrind
See merge request apt-team/apt!378
| -rw-r--r-- | apt-pkg/contrib/extracttar.cc | 12 |
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); } |
