Fix out of bounds read when parsing fstab.

Some fstab files only have 3 fields and mount options are completely omitted.
This commit is contained in:
Oxalica -- 2021-02-22 16:45:48 +00:00 committed by Andrius Štikonas
parent 36dfae351f
commit eea84fb605
1 changed files with 2 additions and 1 deletions

View File

@ -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: