View | Details | Raw Unified | Return to bug 2763 | Differences between
and this patch

Collapse All | Expand All

(-)a/ssh.c (-1 / +28 lines)
Lines 267-272 resolve_host(const char *name, int port, int logerr, char *cname, size_t clen) Link Here
267
	return res;
267
	return res;
268
}
268
}
269
269
270
/* Returns non-zero if name/port represents a single address */
271
static int
272
is_addr(const char *name, int port)
273
{
274
	char strport[NI_MAXSERV];
275
	struct addrinfo hints, *res;
276
	int gaierr;
277
278
	if (port <= 0)
279
		port = default_ssh_port();
280
	snprintf(strport, sizeof strport, "%u", port);
281
	memset(&hints, 0, sizeof(hints));
282
	hints.ai_family = options.address_family == -1 ?
283
	    AF_UNSPEC : options.address_family;
284
	hints.ai_socktype = SOCK_STREAM;
285
	hints.ai_flags = AI_NUMERICHOST|AI_NUMERICSERV;
286
	if ((gaierr = getaddrinfo(name, strport, &hints, &res)) != 0)
287
		return 0;
288
	if (res == NULL || res->ai_next != NULL) {
289
		freeaddrinfo(res);
290
		return 0;
291
	}
292
	freeaddrinfo(res);
293
	return 1;
294
}
295
270
/*
296
/*
271
 * Attempt to resolve a numeric host address / port to a single address.
297
 * Attempt to resolve a numeric host address / port to a single address.
272
 * Returns a canonical address string.
298
 * Returns a canonical address string.
Lines 1027-1033 main(int ac, char **av) Link Here
1027
	}
1053
	}
1028
1054
1029
	/* If canonicalization requested then try to apply it */
1055
	/* If canonicalization requested then try to apply it */
1030
	lowercase(host);
1056
	if (!is_addr(host, options.port))
1057
		lowercase(host);
1031
	if (options.canonicalize_hostname != SSH_CANONICALISE_NO)
1058
	if (options.canonicalize_hostname != SSH_CANONICALISE_NO)
1032
		addrs = resolve_canonicalize(&host, options.port);
1059
		addrs = resolve_canonicalize(&host, options.port);
1033
1060

Return to bug 2763