summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8faa456)
scoped within those functions. It's now dynamically allocated.
git-svn-id: svn://svn.tartarus.org/sgt/putty@1108
cda61777-01e9-0310-a592-
d414129be87e
fprintf(stderr, "Unable to open connection:\n%s", error);
return 1;
}
fprintf(stderr, "Unable to open connection:\n%s", error);
return 1;
}
*
* Returns an error message, or NULL on success.
*
*
* 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)
{
*/
static char *raw_init(char *host, int port, char **realhost)
{
*
* Returns an error message, or NULL on success.
*
*
* 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)
{
*/
static char *rlogin_init(char *host, int port, char **realhost)
{
ssh_scp_init();
if (verbose && realhost != NULL)
tell_user(stderr, "Connected to %s\n", realhost);
ssh_scp_init();
if (verbose && realhost != NULL)
tell_user(stderr, "Connected to %s\n", realhost);
/*
* Connect to specified host and port.
* Returns an error message, or NULL on success.
/*
* 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)
{
*/
static char *connect_to_host(char *host, int port, char **realhost)
{
return err;
#ifdef FWHACK
return err;
#ifdef FWHACK
+ *realhost = strdup(FWhost);
*
* Returns an error message, or NULL on success.
*
*
* 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)
{
*/
static char *telnet_init(char *host, int port, char **realhost)
{
sprintf(msg, "%s - PuTTY", realhost);
title = msg;
}
sprintf(msg, "%s - PuTTY", realhost);
title = msg;
}
set_title(title);
set_icon(title);
}
set_title(title);
set_icon(title);
}
#ifdef IPV6
struct addrinfo *ai; /* Address IPv6 style. */
#endif
#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];
SockAddr ret = smalloc(sizeof(struct SockAddr_tag));
unsigned long a;
struct hostent *h = NULL;
SockAddr ret = smalloc(sizeof(struct SockAddr_tag));
unsigned long a;
struct hostent *h = NULL;
/* 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. */
/* 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. */
if ((a = inet_addr(host)) == (unsigned long) INADDR_NONE) {
#ifdef IPV6
if ((a = inet_addr(host)) == (unsigned long) INADDR_NONE) {
#ifdef IPV6
((struct sockaddr *) ret->ai->ai_addr,
ret->family ==
AF_INET ? sizeof(SOCKADDR_IN) :
((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));
{
memcpy(&a, h->h_addr, sizeof(a));
/* This way we are always sure the h->h_name is valid :) */
{
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));
* success return from inet_addr.
*/
ret->family = AF_INET;
* success return from inet_addr.
*/
ret->family = AF_INET;
+ strncpy(realhost, host, sizeof(realhost));
}
ret->address = ntohl(a);
}
ret->address = ntohl(a);
+ realhost[lenof(realhost)-1] = '\0';
+ *canonicalname = smalloc(1+strlen(realhost));
+ strcpy(*canonicalname, realhost);