mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-16 12:03:03 -05:00
Apply `getservbyname' to the Port Number field in case it's
non-numeric. Patch due to Christian Biesinger. [originally from svn r839]
This commit is contained in:
parent
a24c502f4f
commit
5a908bb1d7
12
windlg.c
12
windlg.c
@ -598,6 +598,8 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
|
|||||||
CHOOSEFONT cf;
|
CHOOSEFONT cf;
|
||||||
LOGFONT lf;
|
LOGFONT lf;
|
||||||
char fontstatic[256];
|
char fontstatic[256];
|
||||||
|
char portname[32];
|
||||||
|
struct servent * service;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
@ -1105,8 +1107,16 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
|
|||||||
sizeof(cfg.host)-1);
|
sizeof(cfg.host)-1);
|
||||||
break;
|
break;
|
||||||
case IDC_PORT:
|
case IDC_PORT:
|
||||||
if (HIWORD(wParam) == EN_CHANGE)
|
if (HIWORD(wParam) == EN_CHANGE) {
|
||||||
|
GetDlgItemText (hwnd, IDC_PORT, portname, 31);
|
||||||
|
if (isdigit(portname[0]))
|
||||||
MyGetDlgItemInt (hwnd, IDC_PORT, &cfg.port);
|
MyGetDlgItemInt (hwnd, IDC_PORT, &cfg.port);
|
||||||
|
else {
|
||||||
|
service = getservbyname(portname, NULL);
|
||||||
|
if (service) cfg.port = ntohs(service->s_port);
|
||||||
|
else cfg.port = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case IDC_SESSEDIT:
|
case IDC_SESSEDIT:
|
||||||
if (HIWORD(wParam) == EN_CHANGE) {
|
if (HIWORD(wParam) == EN_CHANGE) {
|
||||||
|
8
window.c
8
window.c
@ -314,6 +314,14 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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);
|
real_ldisc = (cfg.ldisc_term ? &ldisc_term : &ldisc_simple);
|
||||||
/* To start with, we use the simple line discipline, so we can
|
/* To start with, we use the simple line discipline, so we can
|
||||||
* type passwords etc without fear of them being echoed... */
|
* type passwords etc without fear of them being echoed... */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user