summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJin Qian <jinqian@google.com>2017-05-05 22:01:37 +0200
committerandroid-build-merger <android-build-merger@google.com>2017-05-05 22:01:37 +0200
commit8378187a17898addb0d007ded6becf86120c876b (patch)
tree0b2db4832d8fd63dba0964662d31144c6f0a254c
parentMerge "Update the comment for obsolete symlink handling ." am: a24f9d7cc7 am: e452c25620 am: 4ab07dfcd3 (diff)
parentMerge "recovery: update mkfs.f2fs args to match f2fs-tools 1.8.0" am: f347c1abca am: d6f506e783 (diff)
downloadandroid_bootable_recovery-8378187a17898addb0d007ded6becf86120c876b.tar
android_bootable_recovery-8378187a17898addb0d007ded6becf86120c876b.tar.gz
android_bootable_recovery-8378187a17898addb0d007ded6becf86120c876b.tar.bz2
android_bootable_recovery-8378187a17898addb0d007ded6becf86120c876b.tar.lz
android_bootable_recovery-8378187a17898addb0d007ded6becf86120c876b.tar.xz
android_bootable_recovery-8378187a17898addb0d007ded6becf86120c876b.tar.zst
android_bootable_recovery-8378187a17898addb0d007ded6becf86120c876b.zip
-rw-r--r--roots.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/roots.cpp b/roots.cpp
index 6e5ef9810..727736b70 100644
--- a/roots.cpp
+++ b/roots.cpp
@@ -232,14 +232,14 @@ int format_volume(const char* volume, const char* directory) {
<< ") not supported on " << v->fs_type;
return -1;
}
- char *num_sectors;
- if (asprintf(&num_sectors, "%zd", length / 512) <= 0) {
+ char *num_sectors = nullptr;
+ if (length >= 512 && asprintf(&num_sectors, "%zd", length / 512) <= 0) {
LOG(ERROR) << "format_volume: failed to create " << v->fs_type
<< " command for " << v->blk_device;
return -1;
}
const char *f2fs_path = "/sbin/mkfs.f2fs";
- const char* const f2fs_argv[] = {"mkfs.f2fs", "-t", "-d1", v->blk_device, num_sectors, NULL};
+ const char* const f2fs_argv[] = {"mkfs.f2fs", "-t", "-d1", v->blk_device, num_sectors, nullptr};
result = exec_cmd(f2fs_path, (char* const*)f2fs_argv);
free(num_sectors);