Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion service/diskoperation/filesystems/fat16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,21 @@
cmd = QString("mkfs.fat -F %1 -v -I %2").arg(fat_size).arg(new_partition.getPath());
} else {
qDebug() << "Label is not empty, creating with label";
cmd = QString("mkfs.fat -F %1 -v -I -n %2 %3").arg(fat_size).arg(new_partition.getFileSystemLabel()).arg(new_partition.getPath());
QString label = new_partition.getFileSystemLabel();
bool hasNonAscii = false;
for (const QChar &ch : label) {
if (ch.unicode() > 127) {

Check warning on line 290 in service/diskoperation/filesystems/fat16.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Consider using std::any_of algorithm instead of a raw loop.
hasNonAscii = true;
break;
}
}
if (hasNonAscii) {
cmd = QString("mkfs.fat -F %1 -v -I --codepage=936 -n %2 %3")
.arg(fat_size).arg(label).arg(new_partition.getPath());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Labels with spaces fail formatting

When a non-ASCII volume label contains whitespace, FAT16::create() inserts the label unquoted into the combined command, so command parsing splits it into separate arguments and mkfs.fat receives the wrong -n value and an extra operand; formatting fails.

Pass the label as a single argument instead of interpolating it unquoted into the combined command.

Prompt for AI agents
In `service/diskoperation/filesystems/fat16.cpp` at line 297:

**Labels with spaces fail formatting**

When a non-ASCII volume label contains whitespace, `FAT16::create()` inserts the label unquoted into the combined command, so command parsing splits it into separate arguments and `mkfs.fat` receives the wrong `-n` value and an extra operand; formatting fails.

Pass the label as a single argument instead of interpolating it unquoted into the combined command.

} else {
cmd = QString("mkfs.fat -F %1 -v -I -n %2 %3")
.arg(fat_size).arg(label).arg(new_partition.getPath());
}
}

qDebug() << "FAT16::create***** " << cmd;
Expand Down
Loading