]> andersk Git - openssh.git/blobdiff - canohost.c
- markus@cvs.openbsd.org 2001/03/17 17:27:59
[openssh.git] / canohost.c
index 8253e9b6e714f48c3646c769c8fb097aa851f1b9..52921f5b01526f918ce86a04883d1cd32f76ed34 100644 (file)
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: canohost.c,v 1.20 2001/02/03 10:08:37 markus Exp $");
+RCSID("$OpenBSD: canohost.c,v 1.23 2001/02/10 01:33:32 markus Exp $");
 
 #include "packet.h"
 #include "xmalloc.h"
 #include "log.h"
+#include "canohost.h"
 
 void   check_ip_options(int socket, char *ipaddr);
 
@@ -56,7 +57,7 @@ get_remote_hostname(int socket, int reverse_mapping_check)
                        port = from6->sin6_port;
 
                        memset(&from, 0, sizeof(from));
-                       
+
                        from4->sin_family = AF_INET;
                        memcpy(&from4->sin_addr, &addr, sizeof(addr));
                        from4->sin_port = port;
@@ -70,6 +71,7 @@ get_remote_hostname(int socket, int reverse_mapping_check)
             NULL, 0, NI_NUMERICHOST) != 0)
                fatal("get_remote_hostname: getnameinfo NI_NUMERICHOST failed");
 
+       debug("Trying to reverse map address %.100s.", ntop);
        /* Map the IP address to a host name. */
        if (getnameinfo((struct sockaddr *)&from, fromlen, name, sizeof(name),
             NULL, 0, NI_NAMEREQD) != 0) {
@@ -141,10 +143,10 @@ get_remote_hostname(int socket, int reverse_mapping_check)
 void
 check_ip_options(int socket, char *ipaddr)
 {
-       u_char options[200], *ucp;
-       char text[1024], *cp;
+       u_char options[200];
+       char text[sizeof(options) * 3 + 1];
        socklen_t option_size;
-       int ipproto;
+       int i, ipproto;
        struct protoent *ip;
 
        if ((ip = getprotobyname("ip")) != NULL)
@@ -154,10 +156,10 @@ check_ip_options(int socket, char *ipaddr)
        option_size = sizeof(options);
        if (getsockopt(socket, ipproto, IP_OPTIONS, (void *)options,
            &option_size) >= 0 && option_size != 0) {
-               cp = text;
-               /* Note: "text" buffer must be at least 3x as big as options. */
-               for (ucp = options; option_size > 0; ucp++, option_size--, cp += 3)
-                       sprintf(cp, " %2.2x", *ucp);
+               text[0] = '\0';
+               for (i = 0; i < option_size; i++)
+                       snprintf(text + i*3, sizeof(text) - i*3,
+                           " %2.2x", options[i]);
                log("Connection from %.100s with IP options:%.800s",
                    ipaddr, text);
                packet_disconnect("Connection from %.100s with IP options:%.800s",
This page took 0.033667 seconds and 4 git commands to generate.