[Esbox-commits] r2224 - branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences
eswartz at garage.maemo.org
eswartz at garage.maemo.org
Thu Sep 24 17:21:19 EEST 2009
Author: eswartz
Date: 2009-09-24 17:21:15 +0300 (Thu, 24 Sep 2009)
New Revision: 2224
Modified:
branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/CommonVirtualMachineSettingsPreferencePage.java
Log:
ESbox bug 4595: be sure to validate port numbers
Modified: branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/CommonVirtualMachineSettingsPreferencePage.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/CommonVirtualMachineSettingsPreferencePage.java 2009-09-23 20:01:05 UTC (rev 2223)
+++ branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/CommonVirtualMachineSettingsPreferencePage.java 2009-09-24 14:21:15 UTC (rev 2224)
@@ -26,6 +26,7 @@
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;
@@ -46,6 +47,34 @@
*/
public class CommonVirtualMachineSettingsPreferencePage extends BaseComposableFieldEditorPreferencePage
implements IVirtualMachineSettingsPreferencePage {
+ /**
+ * @author eswartz
+ *
+ */
+ public static class PortFieldEditor extends IntegerFieldEditor {
+ /**
+ * @param name
+ * @param labelText
+ * @param parent
+ * @param textLimit
+ */
+ public PortFieldEditor(String name, String labelText, Composite parent,
+ int textLimit) {
+ super(name, labelText, parent, textLimit);
+ }
+
+ @Override
+ protected boolean checkState() {
+ if (!super.checkState())
+ return false;
+ int port = Integer.parseInt(getTextControl().getText());
+ if (port > 0 && port < 65536)
+ return true;
+ showErrorMessage("Port is invalid (" + port + "); must be between 1 and 65535");
+ return false;
+ }
+ }
+
private StringFieldEditor feUserName;
private StringFieldEditor feUserPassword;
private AddressFieldEditor feSshTargetAddr;
@@ -179,10 +208,10 @@
});
*/
- feSshTargetPort = new IntegerFieldEditor(
- VirtualMachinePreferenceConstants.VM_SSH_TARGET_PORT,
- "Target SSH port:",
- getFieldEditorParent(),
+ feSshTargetPort = new PortFieldEditor(
+ VirtualMachinePreferenceConstants.VM_SSH_TARGET_PORT,
+ "Target SSH port:",
+ getFieldEditorParent(),
5);
addField(feSshTargetPort);
text = feSshTargetPort.getTextControl(getFieldEditorParent());
@@ -203,7 +232,7 @@
String currentHost = getPreferenceStore().getString(feSshHostAddr.getPreferenceName());
hostAddressProvider.setCurrentValue(currentHost);
- feSshHostPort = new IntegerFieldEditor(
+ feSshHostPort = new PortFieldEditor(
VirtualMachinePreferenceConstants.VM_SSH_HOST_PORT,
"Host SSH port:",
getFieldEditorParent(),
@@ -213,7 +242,7 @@
text = feSshHostPort.getTextControl(getFieldEditorParent());
text.setToolTipText("Specify the SSH port visible in the machine.\nThis may be different from the port seen inside the machine,\nespecially if the port is redirected to be visible to the host.");
/*
- feCifsHostPort = new IntegerFieldEditor(
+ feCifsHostPort = new PortFieldEditor(
VirtualMachinePreferenceConstants.VM_CIFS_TARGET_PORT,
"Target Samba port:",
getFieldEditorParent(),
More information about the Esbox-commits
mailing list