Merge "vold: Avoid SIGSEGVs when fstab lacks /data"
am: e3017e0b18
Change-Id: Ib426ece8c295f58750de2526e9ca91c24791b731
diff --git a/cryptfs.cpp b/cryptfs.cpp
index e8bf3aa..4e325e6 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -1451,7 +1451,9 @@
property_get("ro.crypto.readonly", ro_prop, "");
if (strlen(ro_prop) > 0 && atoi(ro_prop)) {
struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab, DATA_MNT_POINT);
- rec->flags |= MS_RDONLY;
+ if (rec) {
+ rec->flags |= MS_RDONLY;
+ }
}
/* If that succeeded, then mount the decrypted filesystem */
@@ -2061,6 +2063,10 @@
if (how == CRYPTO_ENABLE_WIPE) {
struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab, DATA_MNT_POINT);
+ if (!rec) {
+ SLOGE("cryptfs_enable: missing %s entry in fstab\n", DATA_MNT_POINT);
+ return -1;
+ }
int fs_type = get_fs_type(rec);
if (fs_type < 0) {
SLOGE("cryptfs_enable: unsupported fs type %s\n", rec->fs_type);
@@ -2917,7 +2923,7 @@
int cryptfs_isConvertibleToFBE()
{
struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab, DATA_MNT_POINT);
- return fs_mgr_is_convertible_to_fbe(rec) ? 1 : 0;
+ return (rec && fs_mgr_is_convertible_to_fbe(rec)) ? 1 : 0;
}
int cryptfs_create_default_ftr(struct crypt_mnt_ftr* crypt_ftr, __attribute__((unused))int key_length)
@@ -2990,5 +2996,10 @@
const char **filenames_mode_ret)
{
struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab, DATA_MNT_POINT);
+ if (!rec) {
+ *contents_mode_ret = nullptr;
+ *filenames_mode_ret = nullptr;
+ return;
+ }
fs_mgr_get_file_encryption_modes(rec, contents_mode_ret, filenames_mode_ret);
}