Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59af33c9 authored by Bowgo Tsai's avatar Bowgo Tsai
Browse files

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
parent 5b17d713
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -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;