drivesetup: Fix -Wformat-security
Change-Id: Ie5c6d3ea621a1a5704cead8c5e59bf835e907e64 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3322 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
e769acbe80
commit
3d29f848c8
@@ -823,7 +823,7 @@ MainWindow::_DisplayPartitionError(BString _message,
|
|||||||
snprintf(message, sizeof(message), _message.String(), name.String());
|
snprintf(message, sizeof(message), _message.String(), name.String());
|
||||||
} else {
|
} else {
|
||||||
_message.ReplaceAll("%s", "");
|
_message.ReplaceAll("%s", "");
|
||||||
snprintf(message, sizeof(message), _message.String());
|
strlcpy(message, _message.String(), sizeof(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error < B_OK) {
|
if (error < B_OK) {
|
||||||
@@ -985,46 +985,44 @@ MainWindow::_Initialize(BDiskDevice* disk, partition_id selectedPartition,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char message[512];
|
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
snprintf(message, sizeof(message), B_TRANSLATE("Disk system \"%s\" "
|
_DisplayPartitionError(B_TRANSLATE("Disk system \"%s\" not found!"));
|
||||||
"not found!"));
|
|
||||||
_DisplayPartitionError(message);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BString message;
|
||||||
|
|
||||||
if (diskSystem.IsFileSystem()) {
|
if (diskSystem.IsFileSystem()) {
|
||||||
BString intelExtendedPartition = "Intel Extended Partition";
|
BString intelExtendedPartition = "Intel Extended Partition";
|
||||||
if (disk->ID() == selectedPartition) {
|
if (disk->ID() == selectedPartition) {
|
||||||
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
|
message = B_TRANSLATE("Are you sure you "
|
||||||
"want to format a raw disk? (Most people initialize the disk "
|
"want to format a raw disk? (Most people initialize the disk "
|
||||||
"with a partitioning system first) You will be asked "
|
"with a partitioning system first) You will be asked "
|
||||||
"again before changes are written to the disk."));
|
"again before changes are written to the disk.");
|
||||||
} else if (partition->ContentName()
|
} else if (partition->ContentName()
|
||||||
&& strlen(partition->ContentName()) > 0) {
|
&& strlen(partition->ContentName()) > 0) {
|
||||||
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
|
message = B_TRANSLATE("Are you sure you "
|
||||||
"want to format the partition \"%s\"? You will be asked "
|
"want to format the partition \"%s\"? You will be asked "
|
||||||
"again before changes are written to the disk."),
|
"again before changes are written to the disk.");
|
||||||
partition->ContentName());
|
message.ReplaceFirst("%s", partition->ContentName());
|
||||||
} else if (partition->Type() == intelExtendedPartition) {
|
} else if (partition->Type() == intelExtendedPartition) {
|
||||||
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
|
message = B_TRANSLATE("Are you sure you "
|
||||||
"want to format the Intel Extended Partition? Any "
|
"want to format the Intel Extended Partition? Any "
|
||||||
"subpartitions it contains will be overwritten if you "
|
"subpartitions it contains will be overwritten if you "
|
||||||
"continue. You will be asked again before changes are "
|
"continue. You will be asked again before changes are "
|
||||||
"written to the disk."));
|
"written to the disk.");
|
||||||
} else {
|
} else {
|
||||||
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
|
message = B_TRANSLATE("Are you sure you "
|
||||||
"want to format the partition? You will be asked again "
|
"want to format the partition? You will be asked again "
|
||||||
"before changes are written to the disk."));
|
"before changes are written to the disk.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
|
message = B_TRANSLATE("Are you sure you "
|
||||||
"want to initialize the selected disk? All data will be lost. "
|
"want to initialize the selected disk? All data will be lost. "
|
||||||
"You will be asked again before changes are written to the "
|
"You will be asked again before changes are written to the "
|
||||||
"disk.\n"));
|
"disk.\n");
|
||||||
}
|
}
|
||||||
BAlert* alert = new BAlert("first notice", message,
|
BAlert* alert = new BAlert("first notice", message.String(),
|
||||||
B_TRANSLATE("Continue"), B_TRANSLATE("Cancel"), NULL,
|
B_TRANSLATE("Continue"), B_TRANSLATE("Cancel"), NULL,
|
||||||
B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
|
B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
|
||||||
alert->SetShortcut(1, B_ESCAPE);
|
alert->SetShortcut(1, B_ESCAPE);
|
||||||
@@ -1081,30 +1079,32 @@ MainWindow::_Initialize(BDiskDevice* disk, partition_id selectedPartition,
|
|||||||
// Warn the user one more time...
|
// Warn the user one more time...
|
||||||
if (previousName.Length() > 0) {
|
if (previousName.Length() > 0) {
|
||||||
if (partition->IsDevice()) {
|
if (partition->IsDevice()) {
|
||||||
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
|
message = B_TRANSLATE("Are you sure you "
|
||||||
"want to write the changes back to disk now?\n\n"
|
"want to write the changes back to disk now?\n\n"
|
||||||
"All data on the disk %s will be irretrievably lost if you "
|
"All data on the disk %s will be irretrievably lost if you "
|
||||||
"do so!"), previousName.String());
|
"do so!");
|
||||||
|
message.ReplaceFirst("%s", previousName.String());
|
||||||
} else {
|
} else {
|
||||||
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
|
message = B_TRANSLATE("Are you sure you "
|
||||||
"want to write the changes back to disk now?\n\n"
|
"want to write the changes back to disk now?\n\n"
|
||||||
"All data on the partition %s will be irretrievably lost if you "
|
"All data on the partition %s will be irretrievably lost if you "
|
||||||
"do so!"), previousName.String());
|
"do so!");
|
||||||
|
message.ReplaceFirst("%s", previousName.String());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (partition->IsDevice()) {
|
if (partition->IsDevice()) {
|
||||||
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
|
message = B_TRANSLATE("Are you sure you "
|
||||||
"want to write the changes back to disk now?\n\n"
|
"want to write the changes back to disk now?\n\n"
|
||||||
"All data on the selected disk will be irretrievably lost if "
|
"All data on the selected disk will be irretrievably lost if "
|
||||||
"you do so!"));
|
"you do so!");
|
||||||
} else {
|
} else {
|
||||||
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
|
message = B_TRANSLATE("Are you sure you "
|
||||||
"want to write the changes back to disk now?\n\n"
|
"want to write the changes back to disk now?\n\n"
|
||||||
"All data on the selected partition will be irretrievably lost "
|
"All data on the selected partition will be irretrievably lost "
|
||||||
"if you do so!"));
|
"if you do so!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alert = new BAlert("final notice", message,
|
alert = new BAlert("final notice", message.String(),
|
||||||
B_TRANSLATE("Write changes"), B_TRANSLATE("Cancel"), NULL,
|
B_TRANSLATE("Write changes"), B_TRANSLATE("Cancel"), NULL,
|
||||||
B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
|
B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
|
||||||
alert->SetShortcut(1, B_ESCAPE);
|
alert->SetShortcut(1, B_ESCAPE);
|
||||||
|
|||||||
Reference in New Issue
Block a user