X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/5c63c2ab2e7e004fbe2458ed96b32e559d144999..29ec8eb3b38c83e5389fe30f857d34fc86a8efa9:/hostfile.c diff --git a/hostfile.c b/hostfile.c index 2e1c8bcd..2cceb352 100644 --- a/hostfile.c +++ b/hostfile.c @@ -1,3 +1,4 @@ +/* $OpenBSD: hostfile.c,v 1.45 2006/08/03 03:34:42 deraadt Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -36,18 +37,25 @@ */ #include "includes.h" -RCSID("$OpenBSD: hostfile.c,v 1.33 2005/03/01 10:40:26 djm Exp $"); -#include +#include + +#include + #include #include -#include "packet.h" +#include +#include +#include +#include +#include + +#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"); @@ -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 ? */