mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
`realhost', passed back from all the backend init functions, was
scoped within those functions. It's now dynamically allocated. [originally from svn r1108]
This commit is contained in:
parent
d1d65fa6d0
commit
c2eb57a034
1
plink.c
1
plink.c
@ -550,6 +550,7 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "Unable to open connection:\n%s", error);
|
||||
return 1;
|
||||
}
|
||||
sfree(realhost);
|
||||
}
|
||||
connopen = 1;
|
||||
|
||||
|
3
raw.c
3
raw.c
@ -48,7 +48,8 @@ static int raw_receive(Plug plug, int urgent, char *data, int len)
|
||||
*
|
||||
* Returns an error message, or NULL on success.
|
||||
*
|
||||
* Also places the canonical host name into `realhost'.
|
||||
* Also places the canonical host name into `realhost'. It must be
|
||||
* freed by the caller.
|
||||
*/
|
||||
static char *raw_init(char *host, int port, char **realhost)
|
||||
{
|
||||
|
3
rlogin.c
3
rlogin.c
@ -77,7 +77,8 @@ static int rlogin_receive(Plug plug, int urgent, char *data, int len)
|
||||
*
|
||||
* Returns an error message, or NULL on success.
|
||||
*
|
||||
* Also places the canonical host name into `realhost'.
|
||||
* Also places the canonical host name into `realhost'. It must be
|
||||
* freed by the caller.
|
||||
*/
|
||||
static char *rlogin_init(char *host, int port, char **realhost)
|
||||
{
|
||||
|
1
scp.c
1
scp.c
@ -517,6 +517,7 @@ static void do_cmd(char *host, char *user, char *cmd)
|
||||
ssh_scp_init();
|
||||
if (verbose && realhost != NULL)
|
||||
tell_user(stderr, "Connected to %s\n", realhost);
|
||||
sfree(realhost);
|
||||
}
|
||||
|
||||
/*
|
||||
|
5
ssh.c
5
ssh.c
@ -1505,7 +1505,8 @@ static int ssh_receive(Plug plug, int urgent, char *data, int len)
|
||||
/*
|
||||
* Connect to specified host and port.
|
||||
* Returns an error message, or NULL on success.
|
||||
* Also places the canonical host name into `realhost'.
|
||||
* Also places the canonical host name into `realhost'. It must be
|
||||
* freed by the caller.
|
||||
*/
|
||||
static char *connect_to_host(char *host, int port, char **realhost)
|
||||
{
|
||||
@ -1545,7 +1546,7 @@ static char *connect_to_host(char *host, int port, char **realhost)
|
||||
return err;
|
||||
|
||||
#ifdef FWHACK
|
||||
*realhost = FWhost;
|
||||
*realhost = strdup(FWhost);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
3
telnet.c
3
telnet.c
@ -587,7 +587,8 @@ static int telnet_receive(Plug plug, int urgent, char *data, int len)
|
||||
*
|
||||
* Returns an error message, or NULL on success.
|
||||
*
|
||||
* Also places the canonical host name into `realhost'.
|
||||
* Also places the canonical host name into `realhost'. It must be
|
||||
* freed by the caller.
|
||||
*/
|
||||
static char *telnet_init(char *host, int port, char **realhost)
|
||||
{
|
||||
|
1
window.c
1
window.c
@ -476,6 +476,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
sprintf(msg, "%s - PuTTY", realhost);
|
||||
title = msg;
|
||||
}
|
||||
sfree(realhost);
|
||||
set_title(title);
|
||||
set_icon(title);
|
||||
}
|
||||
|
22
winnet.c
22
winnet.c
@ -87,11 +87,6 @@ struct SockAddr_tag {
|
||||
#ifdef IPV6
|
||||
struct addrinfo *ai; /* Address IPv6 style. */
|
||||
#endif
|
||||
/*
|
||||
* We need to have this lengthy enough to hold *any* hostname
|
||||
* (including IPv6 reverse...)
|
||||
*/
|
||||
char realhost[8192];
|
||||
};
|
||||
|
||||
struct buffer {
|
||||
@ -213,11 +208,12 @@ SockAddr sk_namelookup(char *host, char **canonicalname)
|
||||
SockAddr ret = smalloc(sizeof(struct SockAddr_tag));
|
||||
unsigned long a;
|
||||
struct hostent *h = NULL;
|
||||
char realhost[8192];
|
||||
|
||||
/* Clear the structure and default to IPv4. */
|
||||
memset(ret, 0, sizeof(struct SockAddr_tag));
|
||||
ret->family = 0; /* We set this one when we have resolved the host. */
|
||||
*canonicalname = ret->realhost; /* This makes sure we always have a hostname to return. */
|
||||
*realhost = '\0';
|
||||
|
||||
if ((a = inet_addr(host)) == (unsigned long) INADDR_NONE) {
|
||||
#ifdef IPV6
|
||||
@ -312,10 +308,9 @@ SockAddr sk_namelookup(char *host, char **canonicalname)
|
||||
((struct sockaddr *) ret->ai->ai_addr,
|
||||
ret->family ==
|
||||
AF_INET ? sizeof(SOCKADDR_IN) :
|
||||
sizeof(SOCKADDR_IN6), ret->realhost,
|
||||
sizeof(ret->realhost), NULL, 0, 0) != 0) {
|
||||
strncpy(ret->realhost, host,
|
||||
sizeof(ret->realhost));
|
||||
sizeof(SOCKADDR_IN6), realhost,
|
||||
sizeof(realhost), NULL, 0, 0) != 0) {
|
||||
strncpy(realhost, host, sizeof(realhost));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -325,7 +320,7 @@ SockAddr sk_namelookup(char *host, char **canonicalname)
|
||||
{
|
||||
memcpy(&a, h->h_addr, sizeof(a));
|
||||
/* This way we are always sure the h->h_name is valid :) */
|
||||
strncpy(ret->realhost, h->h_name, sizeof(ret->realhost));
|
||||
strncpy(realhost, h->h_name, sizeof(realhost));
|
||||
}
|
||||
}
|
||||
#ifdef IPV6
|
||||
@ -337,9 +332,12 @@ SockAddr sk_namelookup(char *host, char **canonicalname)
|
||||
* success return from inet_addr.
|
||||
*/
|
||||
ret->family = AF_INET;
|
||||
*canonicalname = host;
|
||||
strncpy(realhost, host, sizeof(realhost));
|
||||
}
|
||||
ret->address = ntohl(a);
|
||||
realhost[lenof(realhost)-1] = '\0';
|
||||
*canonicalname = smalloc(1+strlen(realhost));
|
||||
strcpy(*canonicalname, realhost);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user