aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2022-04-06 22:45:57 +0200
committerDioEgizio <83089242+DioEgizio@users.noreply.github.com>2022-04-07 18:28:27 +0200
commit566a83b245b347e3bef72153c2a68dbbf5233ce5 (patch)
tree375a71e4e7094efd57aa16768bca79b148a2d90b
parentcc5261051fcc5ce68177065d9d56fe79c28cbf7e (diff)
downloadPrismLauncher-566a83b245b347e3bef72153c2a68dbbf5233ce5.tar.gz
PrismLauncher-566a83b245b347e3bef72153c2a68dbbf5233ce5.tar.bz2
PrismLauncher-566a83b245b347e3bef72153c2a68dbbf5233ce5.zip
NOISSUE prevent -version being passed to the JRE
We want specific JREs, always, not something that is magically resolved. This counteracts some really bad advice recently being spread on reddit.
-rw-r--r--launcher/JavaCommon.cpp11
-rw-r--r--launcher/LaunchController.cpp5
-rw-r--r--launcher/ui/pages/instance/InstanceSettingsPage.cpp1
3 files changed, 15 insertions, 2 deletions
diff --git a/launcher/JavaCommon.cpp b/launcher/JavaCommon.cpp
index a6542fa7..ce16e8de 100644
--- a/launcher/JavaCommon.cpp
+++ b/launcher/JavaCommon.cpp
@@ -17,6 +17,17 @@ bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget *parent)
QMessageBox::Warning)->exec();
return false;
}
+ // block lunacy with passing required version to the JVM
+ if (jvmargs.contains(QRegExp("-version:.*"))) {
+ auto warnStr = QObject::tr(
+ "You tried to pass required java version argument to the JVM (using \"-version=xxx\"). This is not safe and will not be allowed.\n"
+ "This message will be displayed until you remove this from the JVM arguments.");
+ CustomMessageBox::selectable(
+ parent, QObject::tr("JVM arguments warning"),
+ warnStr,
+ QMessageBox::Warning)->exec();
+ return false;
+ }
return true;
}
diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp
index 792d8381..cc1228f5 100644
--- a/launcher/LaunchController.cpp
+++ b/launcher/LaunchController.cpp
@@ -71,7 +71,10 @@ void LaunchController::executeTask()
return;
}
- JavaCommon::checkJVMArgs(m_instance->settings()->get("JvmArgs").toString(), m_parentWidget);
+ if(!JavaCommon::checkJVMArgs(m_instance->settings()->get("JvmArgs").toString(), m_parentWidget)) {
+ emitFailed(tr("Invalid Java arguments specified. Please fix this first."));
+ return;
+ }
login();
}
diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp
index a5985741..a48c4d69 100644
--- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp
+++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp
@@ -179,7 +179,6 @@ void InstanceSettingsPage::applySettings()
if(javaArgs)
{
m_settings->set("JvmArgs", ui->jvmArgsTextBox->toPlainText().replace("\n", " "));
- JavaCommon::checkJVMArgs(m_settings->get("JvmArgs").toString(), this->parentWidget());
}
else
{