Merge "Fix fastboot to cope with hammerhead\'s implicit hex." am: 2b7b3bd100 am: 4ca547be67
am: 0406de14d0
* commit '0406de14d023918f4cdb3c928b6c2f3f67abf9e5':
Fix fastboot to cope with hammerhead's implicit hex.
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 3b25a82..15dd67d 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -576,7 +576,7 @@
static int64_t get_target_sparse_limit(usb_handle* usb) {
std::string max_download_size;
- if (!fb_getvar(usb, "max-download-size", &max_download_size)) {
+ if (!fb_getvar(usb, "max-download-size", &max_download_size) || max_download_size.empty()) {
fprintf(stderr, "target didn't report max-download-size\n");
return 0;
}
@@ -935,6 +935,10 @@
return;
}
+ // Some bootloaders (hammerhead, for example) use implicit hex.
+ // This code used to use strtol with base 16.
+ if (!android::base::StartsWith(partition_size, "0x")) partition_size = "0x" + partition_size;
+
int64_t size;
if (!android::base::ParseInt(partition_size.c_str(), &size)) {
fprintf(stderr, "Couldn't parse partition size '%s'.\n", partition_size.c_str());