From eea84fb60525803a789e55bb168afb968464c130 Mon Sep 17 00:00:00 2001 From: Oxalica -- Date: Mon, 22 Feb 2021 16:45:48 +0000 Subject: [PATCH] Fix out of bounds read when parsing fstab. Some fstab files only have 3 fields and mount options are completely omitted. --- src/core/fstab.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/fstab.cpp b/src/core/fstab.cpp index 474f8b0..c2d93c9 100644 --- a/src/core/fstab.cpp +++ b/src/core/fstab.cpp @@ -91,7 +91,8 @@ FstabEntryList readFstabEntries( const QString& fstabPath ) auto fsSpec = splitLine.at(0); auto mountPoint = unescapeSpaces(splitLine.at(1)); auto fsType = splitLine.at(2); - auto options = splitLine.at(3); + // Options may be omitted in some rare cases like NixOS generated fstab. + auto options = splitLine.length() >= 4 ? splitLine.at(3) : QString::fromLatin1("defaults"); switch (splitLine.length()) { case 4: