From 6b7a5827ed64b6f32f86e848fbcecd1760677556 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 19 Nov 2019 17:04:39 -0800 Subject: [PATCH] lpdumpd: Do not use stack to store arguments. Bug: 144052321 Test: manual test Change-Id: I700e22ef5c6c0a0c6a5f05c5bb4ea29b0077b34e --- partition_tools/lpdumpd.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/partition_tools/lpdumpd.cc b/partition_tools/lpdumpd.cc index 6110f337..7717e115 100644 --- a/partition_tools/lpdumpd.cc +++ b/partition_tools/lpdumpd.cc @@ -40,18 +40,15 @@ class Lpdump : public BnLpdump { virtual ~Lpdump() = default; Status run(const std::vector& args, std::string* aidl_return) override { - if (args.size() > std::numeric_limits::max()) { - return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT); - } - std::vector m_args = args; - char* argv[m_args.size()]; - for (size_t i = 0; i < m_args.size(); ++i) { - argv[i] = m_args[i].data(); + std::vector local_argv; + std::vector local_args = args; + for (auto& arg : local_args) { + local_argv.push_back(arg.data()); } LOG(DEBUG) << "Dumping with args: " << base::Join(args, " "); std::stringstream output; std::stringstream error; - int ret = LpdumpMain((int)m_args.size(), argv, output, error); + int ret = LpdumpMain((int)local_argv.size(), local_argv.data(), output, error); std::string error_str = error.str(); if (ret == 0) { if (!error_str.empty()) { -- 2.11.0