Loading fastboot/device/fastboot_device.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -137,7 +137,7 @@ void FastbootDevice::ExecuteCommands() { std::string cmd_name; std::string cmd_name; if (android::base::StartsWith(command, "oem ")) { if (android::base::StartsWith(command, "oem ")) { args = {command}; args = {command}; cmd_name = "oem"; cmd_name = FB_CMD_OEM; } else { } else { args = android::base::Split(command, ":"); args = android::base::Split(command, ":"); cmd_name = args[0]; cmd_name = args[0]; Loading fastboot/fastboot.cpp +16 −15 Original line number Original line Diff line number Diff line Loading @@ -64,6 +64,7 @@ #include <ziparchive/zip_archive.h> #include <ziparchive/zip_archive.h> #include "bootimg_utils.h" #include "bootimg_utils.h" #include "constants.h" #include "diagnose_usb.h" #include "diagnose_usb.h" #include "fastboot_driver.h" #include "fastboot_driver.h" #include "fs.h" #include "fs.h" Loading Loading @@ -1697,10 +1698,10 @@ int FastBootTool::Main(int argc, char* argv[]) { while (!args.empty()) { while (!args.empty()) { std::string command = next_arg(&args); std::string command = next_arg(&args); if (command == "getvar") { if (command == FB_CMD_GETVAR) { std::string variable = next_arg(&args); std::string variable = next_arg(&args); DisplayVarOrError(variable, variable); DisplayVarOrError(variable, variable); } else if (command == "erase") { } else if (command == FB_CMD_ERASE) { std::string partition = next_arg(&args); std::string partition = next_arg(&args); auto erase = [&](const std::string& partition) { auto erase = [&](const std::string& partition) { std::string partition_type; std::string partition_type; Loading Loading @@ -1742,7 +1743,7 @@ int FastBootTool::Main(int argc, char* argv[]) { if (data.size() != 256) die("signature must be 256 bytes (got %zu)", data.size()); if (data.size() != 256) die("signature must be 256 bytes (got %zu)", data.size()); fb->Download("signature", data); fb->Download("signature", data); fb->RawCommand("signature", "installing signature"); fb->RawCommand("signature", "installing signature"); } else if (command == "reboot") { } else if (command == FB_CMD_REBOOT) { wants_reboot = true; wants_reboot = true; if (args.size() == 1) { if (args.size() == 1) { Loading @@ -1762,15 +1763,15 @@ int FastBootTool::Main(int argc, char* argv[]) { } } if (!args.empty()) syntax_error("junk after reboot command"); if (!args.empty()) syntax_error("junk after reboot command"); } else if (command == "reboot-bootloader") { } else if (command == FB_CMD_REBOOT_BOOTLOADER) { wants_reboot_bootloader = true; wants_reboot_bootloader = true; } else if (command == "reboot-recovery") { } else if (command == FB_CMD_REBOOT_RECOVERY) { wants_reboot_recovery = true; wants_reboot_recovery = true; } else if (command == "reboot-fastboot") { } else if (command == FB_CMD_REBOOT_FASTBOOT) { wants_reboot_fastboot = true; wants_reboot_fastboot = true; } else if (command == "continue") { } else if (command == FB_CMD_CONTINUE) { fb->Continue(); fb->Continue(); } else if (command == "boot") { } else if (command == FB_CMD_BOOT) { std::string kernel = next_arg(&args); std::string kernel = next_arg(&args); std::string ramdisk; std::string ramdisk; if (!args.empty()) ramdisk = next_arg(&args); if (!args.empty()) ramdisk = next_arg(&args); Loading @@ -1780,7 +1781,7 @@ int FastBootTool::Main(int argc, char* argv[]) { auto data = LoadBootableImage(kernel, ramdisk, second_stage); auto data = LoadBootableImage(kernel, ramdisk, second_stage); fb->Download("boot.img", data); fb->Download("boot.img", data); fb->Boot(); fb->Boot(); } else if (command == "flash") { } else if (command == FB_CMD_FLASH) { std::string pname = next_arg(&args); std::string pname = next_arg(&args); std::string fname; std::string fname; Loading Loading @@ -1827,7 +1828,7 @@ int FastBootTool::Main(int argc, char* argv[]) { } } do_update(filename.c_str(), slot_override, skip_secondary || slot_all); do_update(filename.c_str(), slot_override, skip_secondary || slot_all); wants_reboot = true; wants_reboot = true; } else if (command == "set_active") { } else if (command == FB_CMD_SET_ACTIVE) { std::string slot = verify_slot(next_arg(&args), false); std::string slot = verify_slot(next_arg(&args), false); fb->SetActive(slot); fb->SetActive(slot); } else if (command == "stage") { } else if (command == "stage") { Loading @@ -1841,8 +1842,8 @@ int FastBootTool::Main(int argc, char* argv[]) { } else if (command == "get_staged") { } else if (command == "get_staged") { std::string filename = next_arg(&args); std::string filename = next_arg(&args); fb->Upload(filename); fb->Upload(filename); } else if (command == "oem") { } else if (command == FB_CMD_OEM) { do_oem_command("oem", &args); do_oem_command(FB_CMD_OEM, &args); } else if (command == "flashing") { } else if (command == "flashing") { if (args.empty()) { if (args.empty()) { syntax_error("missing 'flashing' command"); syntax_error("missing 'flashing' command"); Loading @@ -1854,14 +1855,14 @@ int FastBootTool::Main(int argc, char* argv[]) { } else { } else { syntax_error("unknown 'flashing' command %s", args[0].c_str()); syntax_error("unknown 'flashing' command %s", args[0].c_str()); } } } else if (command == "create-logical-partition") { } else if (command == FB_CMD_CREATE_PARTITION) { std::string partition = next_arg(&args); std::string partition = next_arg(&args); std::string size = next_arg(&args); std::string size = next_arg(&args); fb->CreatePartition(partition, size); fb->CreatePartition(partition, size); } else if (command == "delete-logical-partition") { } else if (command == FB_CMD_DELETE_PARTITION) { std::string partition = next_arg(&args); std::string partition = next_arg(&args); fb->DeletePartition(partition); fb->DeletePartition(partition); } else if (command == "resize-logical-partition") { } else if (command == FB_CMD_RESIZE_PARTITION) { std::string partition = next_arg(&args); std::string partition = next_arg(&args); std::string size = next_arg(&args); std::string size = next_arg(&args); fb->ResizePartition(partition, size); fb->ResizePartition(partition, size); Loading fastboot/fastboot_driver.h +2 −3 Original line number Original line Diff line number Diff line Loading @@ -37,15 +37,14 @@ #include <bootimg.h> #include <bootimg.h> #include <inttypes.h> #include <inttypes.h> #include <sparse/sparse.h> #include <sparse/sparse.h> #include "constants.h" #include "transport.h" #include "transport.h" class Transport; class Transport; namespace fastboot { namespace fastboot { static constexpr int FB_COMMAND_SZ = 64; static constexpr int FB_RESPONSE_SZ = 64; enum RetCode : int { enum RetCode : int { SUCCESS = 0, SUCCESS = 0, BAD_ARG, BAD_ARG, Loading fastboot/fuzzy_fastboot/main.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -747,7 +747,7 @@ TEST_F(Fuzz, GetVarAllSpam) { } } TEST_F(Fuzz, BadCommandTooLarge) { TEST_F(Fuzz, BadCommandTooLarge) { std::string s = RandomString(fastboot::FB_COMMAND_SZ + 1, rand_legal); std::string s = RandomString(FB_COMMAND_SZ + 1, rand_legal); EXPECT_EQ(fb->RawCommand(s), DEVICE_FAIL) EXPECT_EQ(fb->RawCommand(s), DEVICE_FAIL) << "Device did not respond with failure after sending length " << s.size() << "Device did not respond with failure after sending length " << s.size() << " string of random ASCII chars"; << " string of random ASCII chars"; Loading Loading
fastboot/device/fastboot_device.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -137,7 +137,7 @@ void FastbootDevice::ExecuteCommands() { std::string cmd_name; std::string cmd_name; if (android::base::StartsWith(command, "oem ")) { if (android::base::StartsWith(command, "oem ")) { args = {command}; args = {command}; cmd_name = "oem"; cmd_name = FB_CMD_OEM; } else { } else { args = android::base::Split(command, ":"); args = android::base::Split(command, ":"); cmd_name = args[0]; cmd_name = args[0]; Loading
fastboot/fastboot.cpp +16 −15 Original line number Original line Diff line number Diff line Loading @@ -64,6 +64,7 @@ #include <ziparchive/zip_archive.h> #include <ziparchive/zip_archive.h> #include "bootimg_utils.h" #include "bootimg_utils.h" #include "constants.h" #include "diagnose_usb.h" #include "diagnose_usb.h" #include "fastboot_driver.h" #include "fastboot_driver.h" #include "fs.h" #include "fs.h" Loading Loading @@ -1697,10 +1698,10 @@ int FastBootTool::Main(int argc, char* argv[]) { while (!args.empty()) { while (!args.empty()) { std::string command = next_arg(&args); std::string command = next_arg(&args); if (command == "getvar") { if (command == FB_CMD_GETVAR) { std::string variable = next_arg(&args); std::string variable = next_arg(&args); DisplayVarOrError(variable, variable); DisplayVarOrError(variable, variable); } else if (command == "erase") { } else if (command == FB_CMD_ERASE) { std::string partition = next_arg(&args); std::string partition = next_arg(&args); auto erase = [&](const std::string& partition) { auto erase = [&](const std::string& partition) { std::string partition_type; std::string partition_type; Loading Loading @@ -1742,7 +1743,7 @@ int FastBootTool::Main(int argc, char* argv[]) { if (data.size() != 256) die("signature must be 256 bytes (got %zu)", data.size()); if (data.size() != 256) die("signature must be 256 bytes (got %zu)", data.size()); fb->Download("signature", data); fb->Download("signature", data); fb->RawCommand("signature", "installing signature"); fb->RawCommand("signature", "installing signature"); } else if (command == "reboot") { } else if (command == FB_CMD_REBOOT) { wants_reboot = true; wants_reboot = true; if (args.size() == 1) { if (args.size() == 1) { Loading @@ -1762,15 +1763,15 @@ int FastBootTool::Main(int argc, char* argv[]) { } } if (!args.empty()) syntax_error("junk after reboot command"); if (!args.empty()) syntax_error("junk after reboot command"); } else if (command == "reboot-bootloader") { } else if (command == FB_CMD_REBOOT_BOOTLOADER) { wants_reboot_bootloader = true; wants_reboot_bootloader = true; } else if (command == "reboot-recovery") { } else if (command == FB_CMD_REBOOT_RECOVERY) { wants_reboot_recovery = true; wants_reboot_recovery = true; } else if (command == "reboot-fastboot") { } else if (command == FB_CMD_REBOOT_FASTBOOT) { wants_reboot_fastboot = true; wants_reboot_fastboot = true; } else if (command == "continue") { } else if (command == FB_CMD_CONTINUE) { fb->Continue(); fb->Continue(); } else if (command == "boot") { } else if (command == FB_CMD_BOOT) { std::string kernel = next_arg(&args); std::string kernel = next_arg(&args); std::string ramdisk; std::string ramdisk; if (!args.empty()) ramdisk = next_arg(&args); if (!args.empty()) ramdisk = next_arg(&args); Loading @@ -1780,7 +1781,7 @@ int FastBootTool::Main(int argc, char* argv[]) { auto data = LoadBootableImage(kernel, ramdisk, second_stage); auto data = LoadBootableImage(kernel, ramdisk, second_stage); fb->Download("boot.img", data); fb->Download("boot.img", data); fb->Boot(); fb->Boot(); } else if (command == "flash") { } else if (command == FB_CMD_FLASH) { std::string pname = next_arg(&args); std::string pname = next_arg(&args); std::string fname; std::string fname; Loading Loading @@ -1827,7 +1828,7 @@ int FastBootTool::Main(int argc, char* argv[]) { } } do_update(filename.c_str(), slot_override, skip_secondary || slot_all); do_update(filename.c_str(), slot_override, skip_secondary || slot_all); wants_reboot = true; wants_reboot = true; } else if (command == "set_active") { } else if (command == FB_CMD_SET_ACTIVE) { std::string slot = verify_slot(next_arg(&args), false); std::string slot = verify_slot(next_arg(&args), false); fb->SetActive(slot); fb->SetActive(slot); } else if (command == "stage") { } else if (command == "stage") { Loading @@ -1841,8 +1842,8 @@ int FastBootTool::Main(int argc, char* argv[]) { } else if (command == "get_staged") { } else if (command == "get_staged") { std::string filename = next_arg(&args); std::string filename = next_arg(&args); fb->Upload(filename); fb->Upload(filename); } else if (command == "oem") { } else if (command == FB_CMD_OEM) { do_oem_command("oem", &args); do_oem_command(FB_CMD_OEM, &args); } else if (command == "flashing") { } else if (command == "flashing") { if (args.empty()) { if (args.empty()) { syntax_error("missing 'flashing' command"); syntax_error("missing 'flashing' command"); Loading @@ -1854,14 +1855,14 @@ int FastBootTool::Main(int argc, char* argv[]) { } else { } else { syntax_error("unknown 'flashing' command %s", args[0].c_str()); syntax_error("unknown 'flashing' command %s", args[0].c_str()); } } } else if (command == "create-logical-partition") { } else if (command == FB_CMD_CREATE_PARTITION) { std::string partition = next_arg(&args); std::string partition = next_arg(&args); std::string size = next_arg(&args); std::string size = next_arg(&args); fb->CreatePartition(partition, size); fb->CreatePartition(partition, size); } else if (command == "delete-logical-partition") { } else if (command == FB_CMD_DELETE_PARTITION) { std::string partition = next_arg(&args); std::string partition = next_arg(&args); fb->DeletePartition(partition); fb->DeletePartition(partition); } else if (command == "resize-logical-partition") { } else if (command == FB_CMD_RESIZE_PARTITION) { std::string partition = next_arg(&args); std::string partition = next_arg(&args); std::string size = next_arg(&args); std::string size = next_arg(&args); fb->ResizePartition(partition, size); fb->ResizePartition(partition, size); Loading
fastboot/fastboot_driver.h +2 −3 Original line number Original line Diff line number Diff line Loading @@ -37,15 +37,14 @@ #include <bootimg.h> #include <bootimg.h> #include <inttypes.h> #include <inttypes.h> #include <sparse/sparse.h> #include <sparse/sparse.h> #include "constants.h" #include "transport.h" #include "transport.h" class Transport; class Transport; namespace fastboot { namespace fastboot { static constexpr int FB_COMMAND_SZ = 64; static constexpr int FB_RESPONSE_SZ = 64; enum RetCode : int { enum RetCode : int { SUCCESS = 0, SUCCESS = 0, BAD_ARG, BAD_ARG, Loading
fastboot/fuzzy_fastboot/main.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -747,7 +747,7 @@ TEST_F(Fuzz, GetVarAllSpam) { } } TEST_F(Fuzz, BadCommandTooLarge) { TEST_F(Fuzz, BadCommandTooLarge) { std::string s = RandomString(fastboot::FB_COMMAND_SZ + 1, rand_legal); std::string s = RandomString(FB_COMMAND_SZ + 1, rand_legal); EXPECT_EQ(fb->RawCommand(s), DEVICE_FAIL) EXPECT_EQ(fb->RawCommand(s), DEVICE_FAIL) << "Device did not respond with failure after sending length " << s.size() << "Device did not respond with failure after sending length " << s.size() << " string of random ASCII chars"; << " string of random ASCII chars"; Loading