diff options
author | Jin Qian <jinqian@google.com> | 2017-05-05 21:53:36 +0200 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-05 21:53:36 +0200 |
commit | 5975ee6a46e16fad5b89b87f9948a648f32aea4c (patch) | |
tree | 9d6ac056b78d8099f7c1df2d93317af19b5817f0 | |
parent | Merge "Update the comment for obsolete symlink handling ." am: a24f9d7cc7 (diff) | |
parent | Merge "recovery: update mkfs.f2fs args to match f2fs-tools 1.8.0" (diff) | |
download | android_bootable_recovery-5975ee6a46e16fad5b89b87f9948a648f32aea4c.tar android_bootable_recovery-5975ee6a46e16fad5b89b87f9948a648f32aea4c.tar.gz android_bootable_recovery-5975ee6a46e16fad5b89b87f9948a648f32aea4c.tar.bz2 android_bootable_recovery-5975ee6a46e16fad5b89b87f9948a648f32aea4c.tar.lz android_bootable_recovery-5975ee6a46e16fad5b89b87f9948a648f32aea4c.tar.xz android_bootable_recovery-5975ee6a46e16fad5b89b87f9948a648f32aea4c.tar.zst android_bootable_recovery-5975ee6a46e16fad5b89b87f9948a648f32aea4c.zip |
-rw-r--r-- | roots.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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); |