diff options
author | Tao Bao <tbao@google.com> | 2019-09-18 13:28:32 -0700 |
---|---|---|
committer | Tao Bao <tbao@google.com> | 2019-09-18 16:12:59 -0700 |
commit | ff185865fd8c634c009b8caa1cc18bffe89f023f (patch) | |
tree | 4f9b2cfc25a9a860d649aa54a4ec4dc05ead3fbf /recovery_main.cpp | |
parent | 2d6e8f2ea8e5ab1ce549f9a6bf9af86ea9eff2a6 (diff) |
recovery: Don't report unrecognized option in recovery_main.
recovery_main is only interested in a subset of options. Suppress the
warning for unrecognized options (which are likely intended for
recovery).
Fixes: 141239600
Test: On Pixel 3a, write `--security` flag into /misc and reboot
recovery. Check that recovery_main no longer reports
"unrecognized option" warning.
# echo "recovery\n--security\n" | \
dd of=/dev/block/by-name/misc conv=notrunc bs=1 seek=64
# killall -9 recovery
# cat /tmp/recovery.log
Test: Write `--show_text=foo` instead, and check that recovery reports
"option `--show_text' doesn't allow an argument".
Change-Id: I1cb3a5ed6db91e41453b8aad00c8608f78ac1fa6
Diffstat (limited to 'recovery_main.cpp')
-rw-r--r-- | recovery_main.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/recovery_main.cpp b/recovery_main.cpp index 28197bf4..a04c1bba 100644 --- a/recovery_main.cpp +++ b/recovery_main.cpp @@ -351,6 +351,12 @@ int main(int argc, char** argv) { std::string locale; std::string reason; + // The code here is only interested in the options that signal the intent to start fastbootd or + // recovery. Unrecognized options are likely meant for recovery, which will be processed later in + // start_recovery(). Suppress the warnings for such -- even if some flags were indeed invalid, the + // code in start_recovery() will capture and report them. + opterr = 0; + int arg; int option_index; while ((arg = getopt_long(args_to_parse.size() - 1, args_to_parse.data(), "", OPTIONS, @@ -374,6 +380,7 @@ int main(int argc, char** argv) { } } optind = 1; + opterr = 1; if (locale.empty()) { if (HasCache()) { |