mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-12 18:13:50 -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
14
windlg.c
14
windlg.c
@ -598,6 +598,8 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
|
||||
CHOOSEFONT cf;
|
||||
LOGFONT lf;
|
||||
char fontstatic[256];
|
||||
char portname[32];
|
||||
struct servent * service;
|
||||
int i;
|
||||
|
||||
switch (msg) {
|
||||
@ -1105,8 +1107,16 @@ static int GenericMainDlgProc (HWND hwnd, UINT 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) {
|
||||
|
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);
|
||||
/* To start with, we use the simple line discipline, so we can
|
||||
* type passwords etc without fear of them being echoed... */
|
||||
|
Loading…
x
Reference in New Issue
Block a user