diff options
author | Tao Bao <tbao@google.com> | 2018-12-20 23:57:27 +0100 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-12-20 23:57:27 +0100 |
commit | 955cf2404d300b5cb4c0090d2599a191049540d2 (patch) | |
tree | 1970ecf335d977f05369625fe58547d608938698 /install.cpp | |
parent | Merge changes from topic "vintf_object_recovery_mount" am: 82fc6ae5b8 am: cc6eb0ee44 (diff) | |
parent | Merge "Clean up the arg setup for exec(3)." am: f0c03e62a2 (diff) | |
download | android_bootable_recovery-955cf2404d300b5cb4c0090d2599a191049540d2.tar android_bootable_recovery-955cf2404d300b5cb4c0090d2599a191049540d2.tar.gz android_bootable_recovery-955cf2404d300b5cb4c0090d2599a191049540d2.tar.bz2 android_bootable_recovery-955cf2404d300b5cb4c0090d2599a191049540d2.tar.lz android_bootable_recovery-955cf2404d300b5cb4c0090d2599a191049540d2.tar.xz android_bootable_recovery-955cf2404d300b5cb4c0090d2599a191049540d2.tar.zst android_bootable_recovery-955cf2404d300b5cb4c0090d2599a191049540d2.zip |
Diffstat (limited to 'install.cpp')
-rw-r--r-- | install.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/install.cpp b/install.cpp index ce3d4f6ad..9d8943f7d 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 |