From 5a97834817dd43b7833881f38f512a9f2fdac8a9 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 7 Dec 2015 14:42:25 +0100 Subject: Avoid overflow when summing up file sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to pass 0llu instead of 0 as the init value, otherwise std::accumulate will calculate with ints. Reported-by: Raphaƫl Hertzog --- apt-pkg/deb/dpkgpm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb/dpkgpm.cc') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 7355af9d5..ce9224791 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1194,7 +1194,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress) std::vector Args(sArgs.size(), NULL); std::transform(sArgs.begin(), sArgs.end(), Args.begin(), [](std::string const &s) { return s.c_str(); }); - unsigned long long const StartSize = std::accumulate(sArgs.begin(), sArgs.end(), 0, + unsigned long long const StartSize = std::accumulate(sArgs.begin(), sArgs.end(), 0llu, [](unsigned long long const i, std::string const &s) { return i + s.length(); }); size_t const BaseArgs = Args.size(); -- cgit v1.2.3