summaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-07-18 05:11:00 +0200
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-07-18 05:11:00 +0200
commit8013f50b03d9ca6424747abddf1657aa4e61dc34 (patch)
tree5bf35c6deefe6bcaeca33b371719f570a0b1147d /recovery.cpp
parentSnap for 4894319 from 399efe580621fb5c22aa163982af4b00122fa4ef to qt-release (diff)
parentMerge "Fix the arguments passed to getopt_long(3)." am: 29932e7bcc am: 2f9d61ad25 (diff)
downloadandroid_bootable_recovery-8013f50b03d9ca6424747abddf1657aa4e61dc34.tar
android_bootable_recovery-8013f50b03d9ca6424747abddf1657aa4e61dc34.tar.gz
android_bootable_recovery-8013f50b03d9ca6424747abddf1657aa4e61dc34.tar.bz2
android_bootable_recovery-8013f50b03d9ca6424747abddf1657aa4e61dc34.tar.lz
android_bootable_recovery-8013f50b03d9ca6424747abddf1657aa4e61dc34.tar.xz
android_bootable_recovery-8013f50b03d9ca6424747abddf1657aa4e61dc34.tar.zst
android_bootable_recovery-8013f50b03d9ca6424747abddf1657aa4e61dc34.zip
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/recovery.cpp b/recovery.cpp
index f6d4212ee..9588cc130 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -983,10 +983,6 @@ static void log_failure_code(ErrorCode code, const std::string& update_package)
}
Device::BuiltinAction start_recovery(Device* device, const std::vector<std::string>& args) {
- std::vector<char*> args_to_parse(args.size());
- std::transform(args.cbegin(), args.cend(), args_to_parse.begin(),
- [](const std::string& arg) { return const_cast<char*>(arg.c_str()); });
-
static constexpr struct option OPTIONS[] = {
{ "fsck_unshare_blocks", no_argument, nullptr, 0 },
{ "just_exit", no_argument, nullptr, 'x' },
@@ -1022,9 +1018,14 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
bool security_update = false;
std::string locale;
+ auto args_to_parse = StringVectorToNullTerminatedArray(args);
+
int arg;
int option_index;
- while ((arg = getopt_long(args_to_parse.size(), args_to_parse.data(), "", OPTIONS,
+ // Parse everything before the last element (which must be a nullptr). getopt_long(3) expects a
+ // null-terminated char* array, but without counting null as an arg (i.e. argv[argc] should be
+ // nullptr).
+ while ((arg = getopt_long(args_to_parse.size() - 1, args_to_parse.data(), "", OPTIONS,
&option_index)) != -1) {
switch (arg) {
case 't':