summaryrefslogtreecommitdiffstats
path: root/fs_mgr
diff options
context:
space:
mode:
authorBowgo Tsai <bowgotsai@google.com>2017-05-24 18:51:36 +0800
committerBowgo Tsai <bowgotsai@google.com>2017-05-24 18:57:16 +0800
commit59af33c9ed6f8436fae599c37f4b8e8e7e9b71fa (patch)
tree5228e2a06d13d7da2b8883785abd306605a9506c /fs_mgr
parent5b17d7131bcb2a00b8b718190a52ed90b26bed8a (diff)
downloadcore-59af33c9ed6f8436fae599c37f4b8e8e7e9b71fa.tar.gz
core-59af33c9ed6f8436fae599c37f4b8e8e7e9b71fa.tar.bz2
core-59af33c9ed6f8436fae599c37f4b8e8e7e9b71fa.zip
fs_mgr: fix SIGSEGV when ostream << nullptr
fstab_rec.fs_options might be nullptr when printing error message. Use android::base::StringPrintf() to '(null)' when needed. Bug: 37759782 Test: Boot device and manaully trigger the output Change-Id: I1bdf4ba57331aaea9dd5e790f6bf9d9b8bdc8b53
Diffstat (limited to 'fs_mgr')
-rw-r--r--fs_mgr/fs_mgr.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index df3c30034..73bdc7a43 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -949,16 +949,20 @@ int fs_mgr_mount_all(struct fstab *fstab, int mount_mode)
}
encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED;
} else {
+ // fs_options might be null so we cannot use PERROR << directly.
+ // Use StringPrintf to output "(null)" instead.
if (fs_mgr_is_nofail(&fstab->recs[attempted_idx])) {
- PERROR << "Ignoring failure to mount an un-encryptable or wiped partition on"
- << fstab->recs[attempted_idx].blk_device << " at "
- << fstab->recs[attempted_idx].mount_point << " options: "
- << fstab->recs[attempted_idx].fs_options;
+ PERROR << android::base::StringPrintf(
+ "Ignoring failure to mount an un-encryptable or wiped "
+ "partition on %s at %s options: %s",
+ fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
+ fstab->recs[attempted_idx].fs_options);
} else {
- PERROR << "Failed to mount an un-encryptable or wiped partition on"
- << fstab->recs[attempted_idx].blk_device << " at "
- << fstab->recs[attempted_idx].mount_point << " options: "
- << fstab->recs[attempted_idx].fs_options;
+ PERROR << android::base::StringPrintf(
+ "Failed to mount an un-encryptable or wiped partition "
+ "on %s at %s options: %s",
+ fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
+ fstab->recs[attempted_idx].fs_options);
++error_count;
}
continue;