Deleted Added
full compact
canohost.c (181110) canohost.c (181111)
1/* $OpenBSD: canohost.c,v 1.61 2006/08/03 03:34:41 deraadt Exp $ */
1/* $OpenBSD: canohost.c,v 1.63 2008/06/12 00:03:49 dtucker Exp $ */
2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * All rights reserved
6 * Functions for returning the canonical host name of the remote site.
7 *
8 * As far as I am concerned, the code I have written for this software
9 * can be used freely for any purpose. Any derived versions of this

--- 17 unchanged lines hidden (view full) ---

27#include <stdlib.h>
28#include <string.h>
29#include <stdarg.h>
30
31#include "xmalloc.h"
32#include "packet.h"
33#include "log.h"
34#include "canohost.h"
2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * All rights reserved
6 * Functions for returning the canonical host name of the remote site.
7 *
8 * As far as I am concerned, the code I have written for this software
9 * can be used freely for any purpose. Any derived versions of this

--- 17 unchanged lines hidden (view full) ---

27#include <stdlib.h>
28#include <string.h>
29#include <stdarg.h>
30
31#include "xmalloc.h"
32#include "packet.h"
33#include "log.h"
34#include "canohost.h"
35#include "misc.h"
35
36static void check_ip_options(int, char *);
37
38/*
39 * Return the canonical name of the host at the other end of the socket. The
40 * caller should free the returned string with xfree.
41 */
42

--- 40 unchanged lines hidden (view full) ---

83 /*
84 * if reverse lookup result looks like a numeric hostname,
85 * someone is trying to trick us by PTR record like following:
86 * 1.1.1.10.in-addr.arpa. IN PTR 2.3.4.5
87 */
88 memset(&hints, 0, sizeof(hints));
89 hints.ai_socktype = SOCK_DGRAM; /*dummy*/
90 hints.ai_flags = AI_NUMERICHOST;
36
37static void check_ip_options(int, char *);
38
39/*
40 * Return the canonical name of the host at the other end of the socket. The
41 * caller should free the returned string with xfree.
42 */
43

--- 40 unchanged lines hidden (view full) ---

84 /*
85 * if reverse lookup result looks like a numeric hostname,
86 * someone is trying to trick us by PTR record like following:
87 * 1.1.1.10.in-addr.arpa. IN PTR 2.3.4.5
88 */
89 memset(&hints, 0, sizeof(hints));
90 hints.ai_socktype = SOCK_DGRAM; /*dummy*/
91 hints.ai_flags = AI_NUMERICHOST;
91 if (getaddrinfo(name, "0", &hints, &ai) == 0) {
92 if (getaddrinfo(name, NULL, &hints, &ai) == 0) {
92 logit("Nasty PTR record \"%s\" is set up for %s, ignoring",
93 name, ntop);
94 freeaddrinfo(ai);
95 return xstrdup(ntop);
96 }
97
98 /*
99 * Convert it to all lowercase (which is expected by the rest

--- 166 unchanged lines hidden (view full) ---

266 addrlen = sizeof(struct sockaddr_in6);
267
268 ipv64_normalise_mapped(&addr, &addrlen);
269
270 /* Get the address in ascii. */
271 if ((r = getnameinfo((struct sockaddr *)&addr, addrlen, ntop,
272 sizeof(ntop), NULL, 0, flags)) != 0) {
273 error("get_socket_address: getnameinfo %d failed: %s", flags,
93 logit("Nasty PTR record \"%s\" is set up for %s, ignoring",
94 name, ntop);
95 freeaddrinfo(ai);
96 return xstrdup(ntop);
97 }
98
99 /*
100 * Convert it to all lowercase (which is expected by the rest

--- 166 unchanged lines hidden (view full) ---

267 addrlen = sizeof(struct sockaddr_in6);
268
269 ipv64_normalise_mapped(&addr, &addrlen);
270
271 /* Get the address in ascii. */
272 if ((r = getnameinfo((struct sockaddr *)&addr, addrlen, ntop,
273 sizeof(ntop), NULL, 0, flags)) != 0) {
274 error("get_socket_address: getnameinfo %d failed: %s", flags,
274 r == EAI_SYSTEM ? strerror(errno) : gai_strerror(r));
275 ssh_gai_strerror(r));
275 return NULL;
276 }
277 return xstrdup(ntop);
278}
279
280char *
281get_peer_ipaddr(int sock)
282{

--- 84 unchanged lines hidden (view full) ---

367 /* Work around Linux IPv6 weirdness */
368 if (from.ss_family == AF_INET6)
369 fromlen = sizeof(struct sockaddr_in6);
370
371 /* Return port number. */
372 if ((r = getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0,
373 strport, sizeof(strport), NI_NUMERICSERV)) != 0)
374 fatal("get_sock_port: getnameinfo NI_NUMERICSERV failed: %s",
276 return NULL;
277 }
278 return xstrdup(ntop);
279}
280
281char *
282get_peer_ipaddr(int sock)
283{

--- 84 unchanged lines hidden (view full) ---

368 /* Work around Linux IPv6 weirdness */
369 if (from.ss_family == AF_INET6)
370 fromlen = sizeof(struct sockaddr_in6);
371
372 /* Return port number. */
373 if ((r = getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0,
374 strport, sizeof(strport), NI_NUMERICSERV)) != 0)
375 fatal("get_sock_port: getnameinfo NI_NUMERICSERV failed: %s",
375 r == EAI_SYSTEM ? strerror(errno) : gai_strerror(r));
376 ssh_gai_strerror(r));
376 return atoi(strport);
377}
378
379/* Returns remote/local port number for the current connection. */
380
381static int
382get_port(int local)
383{

--- 34 unchanged lines hidden ---
377 return atoi(strport);
378}
379
380/* Returns remote/local port number for the current connection. */
381
382static int
383get_port(int local)
384{

--- 34 unchanged lines hidden ---