1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-02 03:52:49 -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:
Simon Tatham
2001-01-07 15:12:20 +00:00
parent a24c502f4f
commit 5a908bb1d7
2 changed files with 20 additions and 2 deletions

View File

@ -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) {