aboutsummaryrefslogtreecommitdiffstats
path: root/install.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-12-20 09:44:06 -0800
committerTao Bao <tbao@google.com>2018-12-20 10:46:06 -0800
commit3d69f0df961b8a79d247ca91dc272c60e504b538 (patch)
treec08c10e3acf70606bf61e1d68b582f72f0aa1572 /install.cpp
parent82fc6ae5b8d118cfa5db0fa8a39625305af7f4ea (diff)
downloadandroid_bootable_recovery-3d69f0df961b8a79d247ca91dc272c60e504b538.tar.gz
android_bootable_recovery-3d69f0df961b8a79d247ca91dc272c60e504b538.tar.bz2
android_bootable_recovery-3d69f0df961b8a79d247ca91dc272c60e504b538.zip
Clean up the arg setup for exec(3).
Test: Build and boot into recovery on marlin. Factory reset. Test: Build and install a non-A/B OTA that calls format. Change-Id: I72416e775e237fc15ca5eff1036175a9eef43b76
Diffstat (limited to 'install.cpp')
-rw-r--r--install.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/install.cpp b/install.cpp
index ce3d4f6a..9d8943f7 100644
--- a/install.cpp
+++ b/install.cpp
@@ -395,12 +395,8 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b
// update attempt.
//
- // Convert the vector to a NULL-terminated char* array suitable for execv.
- const char* chr_args[args.size() + 1];
- chr_args[args.size()] = nullptr;
- for (size_t i = 0; i < args.size(); i++) {
- chr_args[i] = args[i].c_str();
- }
+ // Convert the std::string vector to a NULL-terminated char* vector suitable for execv.
+ auto chr_args = StringVectorToNullTerminatedArray(args);
pid_t pid = fork();
@@ -415,7 +411,7 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b
if (pid == 0) {
umask(022);
close(pipefd[0]);
- execv(chr_args[0], const_cast<char**>(chr_args));
+ execv(chr_args[0], chr_args.data());
// Bug: 34769056
// We shouldn't use LOG/PLOG in the forked process, since they may cause
// the child process to hang. This deadlock results from an improperly