CHOOSEFONT cf;
LOGFONT lf;
char fontstatic[256];
+ char portname[32];
+ struct servent * service;
int i;
switch (msg) {
sizeof(cfg.host)-1);
break;
case IDC_PORT:
- if (HIWORD(wParam) == EN_CHANGE)
- MyGetDlgItemInt (hwnd, IDC_PORT, &cfg.port);
+ if (HIWORD(wParam) == EN_CHANGE) {
+ GetDlgItemText (hwnd, IDC_PORT, portname, 31);
+ if (isdigit(portname[0]))
+ MyGetDlgItemInt (hwnd, IDC_PORT, &cfg.port);
+ else {
+ service = getservbyname(portname, NULL);
+ if (service) cfg.port = ntohs(service->s_port);
+ else cfg.port = 0;
+ }
+ }
break;
case IDC_SESSEDIT:
if (HIWORD(wParam) == EN_CHANGE) {
}
}
+ /* Check for invalid Port number (i.e. zero) */
+ if (cfg.port == 0) {
+ MessageBox(NULL, "Invalid Port Number",
+ "PuTTY Internal Error", MB_OK |MB_ICONEXCLAMATION);
+ WSACleanup();
+ return 1;
+ }
+
real_ldisc = (cfg.ldisc_term ? &ldisc_term : &ldisc_simple);
/* To start with, we use the simple line discipline, so we can
* type passwords etc without fear of them being echoed... */