]> andersk Git - openssh.git/blobdiff - hostfile.c
- (dtucker) Wrap use of IPPROTO_IPV6 in an ifdef for platforms that don't
[openssh.git] / hostfile.c
index 2e1c8bcd0c4ccf4d28cd5b5c8ac5dc7f60be4bc5..cd28bf446c6817b30225c0635804c385d2ce940b 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenBSD: hostfile.c,v 1.46 2009/10/11 23:03:15 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: hostfile.c,v 1.33 2005/03/01 10:40:26 djm Exp $");
 
-#include <resolv.h>
+#include <sys/types.h>
+
+#include <netinet/in.h>
+
 #include <openssl/hmac.h>
 #include <openssl/sha.h>
 
-#include "packet.h"
+#include <resolv.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "xmalloc.h"
 #include "match.h"
 #include "key.h"
 #include "hostfile.h"
 #include "log.h"
-#include "xmalloc.h"
 
 static int
 extract_salt(const char *s, u_int l, char *salt, size_t salt_len)
@@ -88,11 +96,11 @@ extract_salt(const char *s, u_int l, char *salt, size_t salt_len)
                return (-1);
        }
        if (ret != SHA_DIGEST_LENGTH) {
-               debug2("extract_salt: expected salt len %u, got %u",
-                   salt_len, ret);
+               debug2("extract_salt: expected salt len %d, got %d",
+                   SHA_DIGEST_LENGTH, ret);
                return (-1);
        }
-       
+
        return (0);
 }
 
@@ -123,7 +131,7 @@ host_hash(const char *host, const char *name_from_hostfile, u_int src_len)
        HMAC_Final(&mac_ctx, result, NULL);
        HMAC_cleanup(&mac_ctx);
 
-       if (__b64_ntop(salt, len, uu_salt, sizeof(uu_salt)) == -1 || 
+       if (__b64_ntop(salt, len, uu_salt, sizeof(uu_salt)) == -1 ||
            __b64_ntop(result, len, uu_result, sizeof(uu_result)) == -1)
                fatal("host_hash: __b64_ntop failed");
 
@@ -196,7 +204,7 @@ check_host_in_hostfile_by_key_or_type(const char *filename,
        char *cp, *cp2, *hashed_host;
        HostStatus end_return;
 
-       debug3("check_host_in_hostfile: filename %s", filename);
+       debug3("check_host_in_hostfile: host %s filename %s", host, filename);
 
        /* Open the file containing the list of known hosts. */
        f = fopen(filename, "r");
@@ -254,8 +262,10 @@ check_host_in_hostfile_by_key_or_type(const char *filename,
 
                if (key == NULL) {
                        /* we found a key of the requested type */
-                       if (found->type == keytype)
+                       if (found->type == keytype) {
+                               fclose(f);
                                return HOST_FOUND;
+                       }
                        continue;
                }
 
@@ -310,12 +320,12 @@ lookup_key_in_hostfile_by_type(const char *filename, const char *host,
  */
 
 int
-add_host_to_hostfile(const char *filename, const char *host, const Key *key, 
+add_host_to_hostfile(const char *filename, const char *host, const Key *key,
     int store_hash)
 {
        FILE *f;
        int success = 0;
-       char *hashed_host;
+       char *hashed_host = NULL;
 
        if (key == NULL)
                return 1;       /* XXX ? */
This page took 0.107843 seconds and 4 git commands to generate.