From 549baac99671acf9d81e92eb0b69b41744a53f61 Mon Sep 17 00:00:00 2001 From: pavalos Date: Mon, 20 Nov 2006 17:11:41 +0000 Subject: [PATCH] Import OpenSSH 4.5p1. --- crypto/openssh-4/README | 4 +-- crypto/openssh-4/audit-bsm.c | 3 ++- crypto/openssh-4/auth-rsa.c | 10 +++++--- crypto/openssh-4/auth.c | 2 -- crypto/openssh-4/bufbn.c | 12 ++++++--- crypto/openssh-4/clientloop.c | 8 +++--- crypto/openssh-4/dh.c | 2 +- crypto/openssh-4/entropy.c | 1 + crypto/openssh-4/kexdhc.c | 11 ++++++--- crypto/openssh-4/kexdhs.c | 12 +++++---- crypto/openssh-4/kexgexc.c | 11 ++++++--- crypto/openssh-4/kexgexs.c | 12 +++++---- crypto/openssh-4/key.c | 16 ++++++------ crypto/openssh-4/moduli.c | 52 +++++++++++++++++++++++++-------------- crypto/openssh-4/monitor.c | 8 +++--- crypto/openssh-4/monitor_fdpass.c | 3 +++ crypto/openssh-4/rsa.c | 18 ++++++++------ crypto/openssh-4/scard.c | 12 +++++---- crypto/openssh-4/serverloop.c | 8 +++--- crypto/openssh-4/session.c | 2 +- crypto/openssh-4/sftp-client.c | 4 ++- crypto/openssh-4/sftp.c | 3 ++- crypto/openssh-4/ssh-agent.c | 2 +- crypto/openssh-4/ssh-dss.c | 7 +++--- crypto/openssh-4/ssh-keygen.c | 5 ++-- crypto/openssh-4/ssh-keyscan.1 | 4 +-- crypto/openssh-4/ssh-keyscan.c | 2 +- crypto/openssh-4/ssh.1 | 22 ++++++++++++----- crypto/openssh-4/ssh.c | 2 +- crypto/openssh-4/sshconnect.c | 11 ++++----- crypto/openssh-4/sshconnect1.c | 22 +++++++++++------ crypto/openssh-4/sshd.c | 24 ++++++++++-------- 32 files changed, 193 insertions(+), 122 deletions(-) diff --git a/crypto/openssh-4/README b/crypto/openssh-4/README index d0bacc564b..fb53b554b7 100644 --- a/crypto/openssh-4/README +++ b/crypto/openssh-4/README @@ -1,4 +1,4 @@ -See http://www.openssh.com/txt/release-4.4 for the release notes. +See http://www.openssh.com/txt/release-4.5 for the release notes. - A Japanese translation of this document and of the OpenSSH FAQ is - available at http://www.unixuser.org/~haruyama/security/openssh/index.html @@ -62,4 +62,4 @@ References - [6] http://www.openbsd.org/cgi-bin/man.cgi?query=style&sektion=9 [7] http://www.openssh.com/faq.html -$Id: README,v 1.63 2006/09/01 11:32:53 dtucker Exp $ +$Id: README,v 1.64 2006/11/07 12:25:45 dtucker Exp $ diff --git a/crypto/openssh-4/audit-bsm.c b/crypto/openssh-4/audit-bsm.c index d5cf302ce5..c26b4caed7 100644 --- a/crypto/openssh-4/audit-bsm.c +++ b/crypto/openssh-4/audit-bsm.c @@ -1,4 +1,4 @@ -/* $Id: audit-bsm.c,v 1.4 2006/09/01 05:38:36 djm Exp $ */ +/* $Id: audit-bsm.c,v 1.5 2006/09/30 22:09:50 dtucker Exp $ */ /* * TODO @@ -39,6 +39,7 @@ #include +#include #include #include diff --git a/crypto/openssh-4/auth-rsa.c b/crypto/openssh-4/auth-rsa.c index 8c43458b0f..69f9a5896f 100644 --- a/crypto/openssh-4/auth-rsa.c +++ b/crypto/openssh-4/auth-rsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth-rsa.c,v 1.71 2006/08/03 03:34:41 deraadt Exp $ */ +/* $OpenBSD: auth-rsa.c,v 1.72 2006/11/06 21:25:27 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -76,10 +76,12 @@ auth_rsa_generate_challenge(Key *key) if ((challenge = BN_new()) == NULL) fatal("auth_rsa_generate_challenge: BN_new() failed"); /* Generate a random challenge. */ - BN_rand(challenge, 256, 0, 0); + if (BN_rand(challenge, 256, 0, 0) == 0) + fatal("auth_rsa_generate_challenge: BN_rand failed"); if ((ctx = BN_CTX_new()) == NULL) - fatal("auth_rsa_generate_challenge: BN_CTX_new() failed"); - BN_mod(challenge, challenge, key->rsa->n, ctx); + fatal("auth_rsa_generate_challenge: BN_CTX_new failed"); + if (BN_mod(challenge, challenge, key->rsa->n, ctx) == 0) + fatal("auth_rsa_generate_challenge: BN_mod failed"); BN_CTX_free(ctx); return challenge; diff --git a/crypto/openssh-4/auth.c b/crypto/openssh-4/auth.c index db2aa7bf93..5d23343b92 100644 --- a/crypto/openssh-4/auth.c +++ b/crypto/openssh-4/auth.c @@ -569,8 +569,6 @@ fakepw(void) fake.pw_passwd = "$2a$06$r3.juUaHZDlIbQaO2dS9FuYxL1W9M81R1Tc92PoSNmzvpEqLkLGrK"; fake.pw_gecos = "NOUSER"; - fake.pw_uid = (uid_t)-1; - fake.pw_gid = (gid_t)-1; fake.pw_uid = privsep_pw->pw_uid; fake.pw_gid = privsep_pw->pw_gid; #ifdef HAVE_PW_CLASS_IN_PASSWD diff --git a/crypto/openssh-4/bufbn.c b/crypto/openssh-4/bufbn.c index 6cf65d372e..9706ba8a86 100644 --- a/crypto/openssh-4/bufbn.c +++ b/crypto/openssh-4/bufbn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bufbn.c,v 1.3 2006/08/03 03:34:41 deraadt Exp $*/ +/* $OpenBSD: bufbn.c,v 1.4 2006/11/06 21:25:28 markus Exp $*/ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -118,7 +118,10 @@ buffer_get_bignum_ret(Buffer *buffer, BIGNUM *value) return (-1); } bin = buffer_ptr(buffer); - BN_bin2bn(bin, bytes, value); + if (BN_bin2bn(bin, bytes, value) == NULL) { + error("buffer_get_bignum_ret: BN_bin2bn failed"); + return (-1); + } if (buffer_consume_ret(buffer, bytes) == -1) { error("buffer_get_bignum_ret: buffer_consume failed"); return (-1); @@ -202,7 +205,10 @@ buffer_get_bignum2_ret(Buffer *buffer, BIGNUM *value) xfree(bin); return (-1); } - BN_bin2bn(bin, len, value); + if (BN_bin2bn(bin, len, value) == NULL) { + error("buffer_get_bignum2_ret: BN_bin2bn failed"); + return (-1); + } xfree(bin); return (0); } diff --git a/crypto/openssh-4/clientloop.c b/crypto/openssh-4/clientloop.c index 88dfb1f324..4c5108199c 100644 --- a/crypto/openssh-4/clientloop.c +++ b/crypto/openssh-4/clientloop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clientloop.c,v 1.175 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: clientloop.c,v 1.176 2006/10/11 12:38:03 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -464,8 +464,10 @@ client_global_request_reply(int type, u_int32_t seq, void *ctxt) static void server_alive_check(void) { - if (++server_alive_timeouts > options.server_alive_count_max) - packet_disconnect("Timeout, server not responding."); + if (++server_alive_timeouts > options.server_alive_count_max) { + logit("Timeout, server not responding."); + cleanup_exit(255); + } packet_start(SSH2_MSG_GLOBAL_REQUEST); packet_put_cstring("keepalive@openssh.com"); packet_put_char(1); /* boolean: want reply */ diff --git a/crypto/openssh-4/dh.c b/crypto/openssh-4/dh.c index f6ef05cf66..02b9a40816 100644 --- a/crypto/openssh-4/dh.c +++ b/crypto/openssh-4/dh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh.c,v 1.42 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: dh.c,v 1.43 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2000 Niels Provos. All rights reserved. * diff --git a/crypto/openssh-4/entropy.c b/crypto/openssh-4/entropy.c index 4f19c87675..ccabb13644 100644 --- a/crypto/openssh-4/entropy.c +++ b/crypto/openssh-4/entropy.c @@ -36,6 +36,7 @@ #endif #include #include +#include #include #include diff --git a/crypto/openssh-4/kexdhc.c b/crypto/openssh-4/kexdhc.c index 64de7af308..d384c8052b 100644 --- a/crypto/openssh-4/kexdhc.c +++ b/crypto/openssh-4/kexdhc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kexdhc.c,v 1.9 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: kexdhc.c,v 1.11 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -50,7 +50,8 @@ kexdh_client(Kex *kex) Key *server_host_key; u_char *server_host_key_blob = NULL, *signature = NULL; u_char *kbuf, *hash; - u_int klen, kout, slen, sbloblen, hashlen; + u_int klen, slen, sbloblen, hashlen; + int kout; /* generate and send 'e', client DH public key */ switch (kex->kex_type) { @@ -112,13 +113,15 @@ kexdh_client(Kex *kex) klen = DH_size(dh); kbuf = xmalloc(klen); - kout = DH_compute_key(kbuf, dh_server_pub, dh); + if ((kout = DH_compute_key(kbuf, dh_server_pub, dh)) < 0) + fatal("DH_compute_key: failed"); #ifdef DEBUG_KEXDH dump_digest("shared secret", kbuf, kout); #endif if ((shared_secret = BN_new()) == NULL) fatal("kexdh_client: BN_new failed"); - BN_bin2bn(kbuf, kout, shared_secret); + if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) + fatal("kexdh_client: BN_bin2bn failed"); memset(kbuf, 0, klen); xfree(kbuf); diff --git a/crypto/openssh-4/kexdhs.c b/crypto/openssh-4/kexdhs.c index 93ec97f931..8617088184 100644 --- a/crypto/openssh-4/kexdhs.c +++ b/crypto/openssh-4/kexdhs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kexdhs.c,v 1.7 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: kexdhs.c,v 1.9 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -52,8 +52,8 @@ kexdh_server(Kex *kex) DH *dh; Key *server_host_key; u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; - u_int sbloblen, klen, kout, hashlen; - u_int slen; + u_int sbloblen, klen, hashlen, slen; + int kout; /* generate server DH public key */ switch (kex->kex_type) { @@ -101,13 +101,15 @@ kexdh_server(Kex *kex) klen = DH_size(dh); kbuf = xmalloc(klen); - kout = DH_compute_key(kbuf, dh_client_pub, dh); + if ((kout = DH_compute_key(kbuf, dh_client_pub, dh)) < 0) + fatal("DH_compute_key: failed"); #ifdef DEBUG_KEXDH dump_digest("shared secret", kbuf, kout); #endif if ((shared_secret = BN_new()) == NULL) fatal("kexdh_server: BN_new failed"); - BN_bin2bn(kbuf, kout, shared_secret); + if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) + fatal("kexdh_server: BN_bin2bn failed"); memset(kbuf, 0, klen); xfree(kbuf); diff --git a/crypto/openssh-4/kexgexc.c b/crypto/openssh-4/kexgexc.c index 2c19713e11..adb973d5b4 100644 --- a/crypto/openssh-4/kexgexc.c +++ b/crypto/openssh-4/kexgexc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kexgexc.c,v 1.9 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: kexgexc.c,v 1.11 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2000 Niels Provos. All rights reserved. * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -51,7 +51,8 @@ kexgex_client(Kex *kex) BIGNUM *p = NULL, *g = NULL; Key *server_host_key; u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; - u_int klen, kout, slen, sbloblen, hashlen; + u_int klen, slen, sbloblen, hashlen; + int kout; int min, max, nbits; DH *dh; @@ -150,13 +151,15 @@ kexgex_client(Kex *kex) klen = DH_size(dh); kbuf = xmalloc(klen); - kout = DH_compute_key(kbuf, dh_server_pub, dh); + if ((kout = DH_compute_key(kbuf, dh_server_pub, dh)) < 0) + fatal("DH_compute_key: failed"); #ifdef DEBUG_KEXDH dump_digest("shared secret", kbuf, kout); #endif if ((shared_secret = BN_new()) == NULL) fatal("kexgex_client: BN_new failed"); - BN_bin2bn(kbuf, kout, shared_secret); + if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) + fatal("kexgex_client: BN_bin2bn failed"); memset(kbuf, 0, klen); xfree(kbuf); diff --git a/crypto/openssh-4/kexgexs.c b/crypto/openssh-4/kexgexs.c index 5373a633a4..a037f57f28 100644 --- a/crypto/openssh-4/kexgexs.c +++ b/crypto/openssh-4/kexgexs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kexgexs.c,v 1.8 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: kexgexs.c,v 1.10 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2000 Niels Provos. All rights reserved. * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -55,8 +55,8 @@ kexgex_server(Kex *kex) Key *server_host_key; DH *dh; u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; - u_int sbloblen, klen, kout, slen, hashlen; - int min = -1, max = -1, nbits = -1, type; + u_int sbloblen, klen, slen, hashlen; + int min = -1, max = -1, nbits = -1, type, kout; if (kex->load_host_key == NULL) fatal("Cannot load hostkey"); @@ -134,13 +134,15 @@ kexgex_server(Kex *kex) klen = DH_size(dh); kbuf = xmalloc(klen); - kout = DH_compute_key(kbuf, dh_client_pub, dh); + if ((kout = DH_compute_key(kbuf, dh_client_pub, dh)) < 0) + fatal("DH_compute_key: failed"); #ifdef DEBUG_KEXDH dump_digest("shared secret", kbuf, kout); #endif if ((shared_secret = BN_new()) == NULL) fatal("kexgex_server: BN_new failed"); - BN_bin2bn(kbuf, kout, shared_secret); + if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) + fatal("kexgex_server: BN_bin2bn failed"); memset(kbuf, 0, klen); xfree(kbuf); diff --git a/crypto/openssh-4/key.c b/crypto/openssh-4/key.c index f3b3d6b946..93b2d41fed 100644 --- a/crypto/openssh-4/key.c +++ b/crypto/openssh-4/key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key.c,v 1.67 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: key.c,v 1.68 2006/11/06 21:25:28 markus Exp $ */ /* * read_bignum(): * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -617,16 +617,18 @@ key_from_private(const Key *k) switch (k->type) { case KEY_DSA: n = key_new(k->type); - BN_copy(n->dsa->p, k->dsa->p); - BN_copy(n->dsa->q, k->dsa->q); - BN_copy(n->dsa->g, k->dsa->g); - BN_copy(n->dsa->pub_key, k->dsa->pub_key); + if ((BN_copy(n->dsa->p, k->dsa->p) == NULL) || + (BN_copy(n->dsa->q, k->dsa->q) == NULL) || + (BN_copy(n->dsa->g, k->dsa->g) == NULL) || + (BN_copy(n->dsa->pub_key, k->dsa->pub_key) == NULL)) + fatal("key_from_private: BN_copy failed"); break; case KEY_RSA: case KEY_RSA1: n = key_new(k->type); - BN_copy(n->rsa->n, k->rsa->n); - BN_copy(n->rsa->e, k->rsa->e); + if ((BN_copy(n->rsa->n, k->rsa->n) == NULL) || + (BN_copy(n->rsa->e, k->rsa->e) == NULL)) + fatal("key_from_private: BN_copy failed"); break; default: fatal("key_from_private: unknown type %d", k->type); diff --git a/crypto/openssh-4/moduli.c b/crypto/openssh-4/moduli.c index e18929badd..44e5ddfc0c 100644 --- a/crypto/openssh-4/moduli.c +++ b/crypto/openssh-4/moduli.c @@ -1,4 +1,4 @@ -/* $OpenBSD: moduli.c,v 1.18 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: moduli.c,v 1.19 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright 1994 Phil Karn * Copyright 1996-1998, 2003 William Allen Simpson @@ -327,20 +327,26 @@ gen_candidates(FILE *out, u_int32_t memory, u_int32_t power, BIGNUM *start) /* validation check: count the number of primes tried */ largetries = 0; - q = BN_new(); + if ((q = BN_new()) == NULL) + fatal("BN_new failed"); /* * Generate random starting point for subprime search, or use * specified parameter. */ - largebase = BN_new(); - if (start == NULL) - BN_rand(largebase, power, 1, 1); - else - BN_copy(largebase, start); + if ((largebase = BN_new()) == NULL) + fatal("BN_new failed"); + if (start == NULL) { + if (BN_rand(largebase, power, 1, 1) == 0) + fatal("BN_rand failed"); + } else { + if (BN_copy(largebase, start) == NULL) + fatal("BN_copy: failed"); + } /* ensure odd */ - BN_set_bit(largebase, 0); + if (BN_set_bit(largebase, 0) == 0) + fatal("BN_set_bit: failed"); time(&time_start); @@ -424,8 +430,10 @@ gen_candidates(FILE *out, u_int32_t memory, u_int32_t power, BIGNUM *start) continue; /* Definitely composite, skip */ debug2("test q = largebase+%u", 2 * j); - BN_set_word(q, 2 * j); - BN_add(q, q, largebase); + if (BN_set_word(q, 2 * j) == 0) + fatal("BN_set_word failed"); + if (BN_add(q, q, largebase) == 0) + fatal("BN_add failed"); if (qfileout(out, QTYPE_SOPHIE_GERMAIN, QTEST_SIEVE, largetries, (power - 1) /* MSB */, (0), q) == -1) { ret = -1; @@ -470,9 +478,12 @@ prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted) time(&time_start); - p = BN_new(); - q = BN_new(); - ctx = BN_CTX_new(); + if ((p = BN_new()) == NULL) + fatal("BN_new failed"); + if ((q = BN_new()) == NULL) + fatal("BN_new failed"); + if ((ctx = BN_CTX_new()) == NULL) + fatal("BN_CTX_new failed"); debug2("%.24s Final %u Miller-Rabin trials (%x generator)", ctime(&time_start), trials, generator_wanted); @@ -520,10 +531,13 @@ prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted) case QTYPE_SOPHIE_GERMAIN: debug2("%10u: (%u) Sophie-Germain", count_in, in_type); a = q; - BN_hex2bn(&a, cp); + if (BN_hex2bn(&a, cp) == 0) + fatal("BN_hex2bn failed"); /* p = 2*q + 1 */ - BN_lshift(p, q, 1); - BN_add_word(p, 1); + if (BN_lshift(p, q, 1) == 0) + fatal("BN_lshift failed"); + if (BN_add_word(p, 1) == 0) + fatal("BN_add_word failed"); in_size += 1; generator_known = 0; break; @@ -534,9 +548,11 @@ prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted) case QTYPE_UNKNOWN: debug2("%10u: (%u)", count_in, in_type); a = p; - BN_hex2bn(&a, cp); + if (BN_hex2bn(&a, cp) == 0) + fatal("BN_hex2bn failed"); /* q = (p-1) / 2 */ - BN_rshift(q, p, 1); + if (BN_rshift(q, p, 1) == 0) + fatal("BN_rshift failed"); break; default: debug2("Unknown prime type"); diff --git a/crypto/openssh-4/monitor.c b/crypto/openssh-4/monitor.c index b20d0c726a..48ae46cccb 100644 --- a/crypto/openssh-4/monitor.c +++ b/crypto/openssh-4/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.88 2006/08/12 20:46:46 miod Exp $ */ +/* $OpenBSD: monitor.c,v 1.89 2006/11/07 10:31:31 markus Exp $ */ /* * Copyright 2002 Niels Provos * Copyright 2002 Markus Friedl @@ -350,7 +350,7 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor) /* The first few requests do not require asynchronous access */ while (!authenticated) { auth_method = "unknown"; - authenticated = monitor_read(pmonitor, mon_dispatch, &ent); + authenticated = (monitor_read(pmonitor, mon_dispatch, &ent) == 1); if (authenticated) { if (!(ent->flags & MON_AUTHDECIDE)) fatal("%s: unexpected authentication from %d", @@ -1217,7 +1217,7 @@ mm_answer_keyverify(int sock, Buffer *m) verified = key_verify(key, signature, signaturelen, data, datalen); debug3("%s: key %p signature %s", - __func__, key, verified ? "verified" : "unverified"); + __func__, key, (verified == 1) ? "verified" : "unverified"); key_free(key); xfree(blob); @@ -1232,7 +1232,7 @@ mm_answer_keyverify(int sock, Buffer *m) buffer_put_int(m, verified); mm_request_send(sock, MONITOR_ANS_KEYVERIFY, m); - return (verified); + return (verified == 1); } static void diff --git a/crypto/openssh-4/monitor_fdpass.c b/crypto/openssh-4/monitor_fdpass.c index c5fc4c3970..9f8e9cd550 100644 --- a/crypto/openssh-4/monitor_fdpass.c +++ b/crypto/openssh-4/monitor_fdpass.c @@ -29,6 +29,9 @@ #include #include #include +#ifdef HAVE_SYS_UN_H +#include +#endif #include #include diff --git a/crypto/openssh-4/rsa.c b/crypto/openssh-4/rsa.c index 08cc820071..bec1d190bc 100644 --- a/crypto/openssh-4/rsa.c +++ b/crypto/openssh-4/rsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa.c,v 1.28 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: rsa.c,v 1.29 2006/11/06 21:25:28 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -91,7 +91,8 @@ rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA *key) RSA_PKCS1_PADDING)) <= 0) fatal("rsa_public_encrypt() failed"); - BN_bin2bn(outbuf, len, out); + if (BN_bin2bn(outbuf, len, out) == NULL) + fatal("rsa_public_encrypt: BN_bin2bn failed"); memset(outbuf, 0, olen); memset(inbuf, 0, ilen); @@ -116,7 +117,8 @@ rsa_private_decrypt(BIGNUM *out, BIGNUM *in, RSA *key) RSA_PKCS1_PADDING)) <= 0) { error("rsa_private_decrypt() failed"); } else { - BN_bin2bn(outbuf, len, out); + if (BN_bin2bn(outbuf, len, out) == NULL) + fatal("rsa_private_decrypt: BN_bin2bn failed"); } memset(outbuf, 0, olen); memset(inbuf, 0, ilen); @@ -137,11 +139,11 @@ rsa_generate_additional_parameters(RSA *rsa) if ((ctx = BN_CTX_new()) == NULL) fatal("rsa_generate_additional_parameters: BN_CTX_new failed"); - BN_sub(aux, rsa->q, BN_value_one()); - BN_mod(rsa->dmq1, rsa->d, aux, ctx); - - BN_sub(aux, rsa->p, BN_value_one()); - BN_mod(rsa->dmp1, rsa->d, aux, ctx); + if ((BN_sub(aux, rsa->q, BN_value_one()) == 0) || + (BN_mod(rsa->dmq1, rsa->d, aux, ctx) == 0) || + (BN_sub(aux, rsa->p, BN_value_one()) == 0) || + (BN_mod(rsa->dmp1, rsa->d, aux, ctx) == 0)) + fatal("rsa_generate_additional_parameters: BN_sub/mod failed"); BN_clear_free(aux); BN_CTX_free(ctx); diff --git a/crypto/openssh-4/scard.c b/crypto/openssh-4/scard.c index 328655eddb..9fd3ca1b4e 100644 --- a/crypto/openssh-4/scard.c +++ b/crypto/openssh-4/scard.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scard.c,v 1.35 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: scard.c,v 1.36 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -391,15 +391,17 @@ sc_get_keys(const char *id, const char *pin) keys = xcalloc((nkeys+1), sizeof(Key *)); n = key_new(KEY_RSA1); - BN_copy(n->rsa->n, k->rsa->n); - BN_copy(n->rsa->e, k->rsa->e); + if ((BN_copy(n->rsa->n, k->rsa->n) == NULL) || + (BN_copy(n->rsa->e, k->rsa->e) == NULL)) + fatal("sc_get_keys: BN_copy failed"); RSA_set_method(n->rsa, sc_get_rsa()); n->flags |= KEY_FLAG_EXT; keys[0] = n; n = key_new(KEY_RSA); - BN_copy(n->rsa->n, k->rsa->n); - BN_copy(n->rsa->e, k->rsa->e); + if ((BN_copy(n->rsa->n, k->rsa->n) == NULL) || + (BN_copy(n->rsa->e, k->rsa->e) == NULL)) + fatal("sc_get_keys: BN_copy failed"); RSA_set_method(n->rsa, sc_get_rsa()); n->flags |= KEY_FLAG_EXT; keys[1] = n; diff --git a/crypto/openssh-4/serverloop.c b/crypto/openssh-4/serverloop.c index 6e5fdc2d8c..69304b5fad 100644 --- a/crypto/openssh-4/serverloop.c +++ b/crypto/openssh-4/serverloop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: serverloop.c,v 1.144 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: serverloop.c,v 1.145 2006/10/11 12:38:03 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -248,8 +248,10 @@ client_alive_check(void) int channel_id; /* timeout, check to see how many we have had */ - if (++client_alive_timeouts > options.client_alive_count_max) - packet_disconnect("Timeout, your session not responding."); + if (++client_alive_timeouts > options.client_alive_count_max) { + logit("Timeout, client not responding."); + cleanup_exit(255); + } /* * send a bogus global/channel request with "wantreply", diff --git a/crypto/openssh-4/session.c b/crypto/openssh-4/session.c index 15c5ca9a02..69153ad1e3 100644 --- a/crypto/openssh-4/session.c +++ b/crypto/openssh-4/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.219 2006/08/29 10:40:19 djm Exp $ */ +/* $OpenBSD: session.c,v 1.220 2006/10/09 23:36:11 djm Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland * All rights reserved diff --git a/crypto/openssh-4/sftp-client.c b/crypto/openssh-4/sftp-client.c index e31b2cfafa..42eb2b41bf 100644 --- a/crypto/openssh-4/sftp-client.c +++ b/crypto/openssh-4/sftp-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-client.c,v 1.74 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: sftp-client.c,v 1.75 2006/10/22 02:25:50 djm Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -1134,6 +1134,8 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path, if (status != SSH2_FX_OK) { error("Couldn't write to remote file \"%s\": %s", remote_path, fx2txt(status)); + if (showprogress) + stop_progress_meter(); do_close(conn, handle, handle_len); close(local_fd); xfree(data); diff --git a/crypto/openssh-4/sftp.c b/crypto/openssh-4/sftp.c index c018615ae6..a39c782f70 100644 --- a/crypto/openssh-4/sftp.c +++ b/crypto/openssh-4/sftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp.c,v 1.92 2006/09/19 05:52:23 otto Exp $ */ +/* $OpenBSD: sftp.c,v 1.93 2006/09/30 17:48:22 ray Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -977,6 +977,7 @@ parse_args(const char **cpp, int *pflag, int *lflag, int *iflag, case I_CHOWN: case I_CHGRP: /* Get numeric arg (mandatory) */ + errno = 0; l = strtol(cp, &cp2, base); if (cp2 == cp || ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE) || l < 0) { diff --git a/crypto/openssh-4/ssh-agent.c b/crypto/openssh-4/ssh-agent.c index 08b07212e0..ef95eb878f 100644 --- a/crypto/openssh-4/ssh-agent.c +++ b/crypto/openssh-4/ssh-agent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-agent.c,v 1.152 2006/08/04 20:46:05 stevesk Exp $ */ +/* $OpenBSD: ssh-agent.c,v 1.153 2006/10/06 02:29:19 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland diff --git a/crypto/openssh-4/ssh-dss.c b/crypto/openssh-4/ssh-dss.c index fbc078e84d..51a06e98fe 100644 --- a/crypto/openssh-4/ssh-dss.c +++ b/crypto/openssh-4/ssh-dss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-dss.c,v 1.23 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: ssh-dss.c,v 1.24 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -161,8 +161,9 @@ ssh_dss_verify(const Key *key, const u_char *signature, u_int signaturelen, fatal("ssh_dss_verify: BN_new failed"); if ((sig->s = BN_new()) == NULL) fatal("ssh_dss_verify: BN_new failed"); - BN_bin2bn(sigblob, INTBLOB_LEN, sig->r); - BN_bin2bn(sigblob+ INTBLOB_LEN, INTBLOB_LEN, sig->s); + if ((BN_bin2bn(sigblob, INTBLOB_LEN, sig->r) == NULL) || + (BN_bin2bn(sigblob+ INTBLOB_LEN, INTBLOB_LEN, sig->s) == NULL)) + fatal("ssh_dss_verify: BN_bin2bn failed"); /* clean up */ memset(sigblob, 0, len); diff --git a/crypto/openssh-4/ssh-keygen.c b/crypto/openssh-4/ssh-keygen.c index 969bd23590..1f42b93585 100644 --- a/crypto/openssh-4/ssh-keygen.c +++ b/crypto/openssh-4/ssh-keygen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-keygen.c,v 1.154 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: ssh-keygen.c,v 1.155 2006/11/06 21:25:28 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1994 Tatu Ylonen , Espoo, Finland @@ -222,7 +222,8 @@ buffer_get_bignum_bits(Buffer *b, BIGNUM *value) if (buffer_len(b) < bytes) fatal("buffer_get_bignum_bits: input buffer too small: " "need %d have %d", bytes, buffer_len(b)); - BN_bin2bn(buffer_ptr(b), bytes, value); + if (BN_bin2bn(buffer_ptr(b), bytes, value) == NULL) + fatal("buffer_get_bignum_bits: BN_bin2bn failed"); buffer_consume(b, bytes); } diff --git a/crypto/openssh-4/ssh-keyscan.1 b/crypto/openssh-4/ssh-keyscan.1 index 80fc8cd960..a3656fc779 100644 --- a/crypto/openssh-4/ssh-keyscan.1 +++ b/crypto/openssh-4/ssh-keyscan.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ssh-keyscan.1,v 1.21 2005/09/30 20:34:26 jaredy Exp $ +.\" $OpenBSD: ssh-keyscan.1,v 1.22 2006/09/25 04:55:38 ray Exp $ .\" .\" Copyright 1995, 1996 by David Mazieres . .\" @@ -102,7 +102,7 @@ Causes to print debugging messages about its progress. .El .Sh SECURITY -If a ssh_known_hosts file is constructed using +If an ssh_known_hosts file is constructed using .Nm without verifying the keys, users will be vulnerable to .Em man in the middle diff --git a/crypto/openssh-4/ssh-keyscan.c b/crypto/openssh-4/ssh-keyscan.c index 416d3f5c14..b19864007b 100644 --- a/crypto/openssh-4/ssh-keyscan.c +++ b/crypto/openssh-4/ssh-keyscan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-keyscan.c,v 1.73 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: ssh-keyscan.c,v 1.74 2006/10/06 02:29:19 djm Exp $ */ /* * Copyright 1995, 1996 by David Mazieres . * diff --git a/crypto/openssh-4/ssh.1 b/crypto/openssh-4/ssh.1 index 6e41bcd8ba..93be52f96b 100644 --- a/crypto/openssh-4/ssh.1 +++ b/crypto/openssh-4/ssh.1 @@ -34,7 +34,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: ssh.1,v 1.263 2006/07/11 18:50:48 markus Exp $ +.\" $OpenBSD: ssh.1,v 1.265 2006/10/28 18:08:10 otto Exp $ .Dd September 25, 1999 .Dt SSH 1 .Os @@ -1077,12 +1077,22 @@ controls whether the server supports this, and at what level (layer 2 or 3 traffic). .Pp The following example would connect client network 10.0.50.0/24 -with remote network 10.0.99.0/24, provided that the SSH server -running on the gateway to the remote network, -at 192.168.1.15, allows it: +with remote network 10.0.99.0/24 using a point-to-point connection +from 10.1.1.1 to 10.1.1.2, +provided that the SSH server running on the gateway to the remote network, +at 192.168.1.15, allows it. +.Pp +On the client: .Bd -literal -offset indent # ssh -f -w 0:1 192.168.1.15 true -# ifconfig tun0 10.0.50.1 10.0.99.1 netmask 255.255.255.252 +# ifconfig tun0 10.1.1.1 10.1.1.2 netmask 255.255.255.252 +# route add 10.0.99.0/24 10.1.1.2 +.Ed +.Pp +On the server: +.Bd -literal -offset indent +# ifconfig tun1 10.1.1.2 10.1.1.1 netmask 255.255.255.252 +# route add 10.0.50.0/24 10.1.1.1 .Ed .Pp Client access may be more finely tuned via the @@ -1105,7 +1115,7 @@ tunnel="1",command="sh /etc/netstart tun1" ssh-rsa ... jane tunnel="2",command="sh /etc/netstart tun2" ssh-rsa ... john .Ed .Pp -Since a SSH-based setup entails a fair amount of overhead, +Since an SSH-based setup entails a fair amount of overhead, it may be more suited to temporary setups, such as for wireless VPNs. More permanent VPNs are better provided by tools such as diff --git a/crypto/openssh-4/ssh.c b/crypto/openssh-4/ssh.c index efc4af6d43..47297edbb3 100644 --- a/crypto/openssh-4/ssh.c +++ b/crypto/openssh-4/ssh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh.c,v 1.293 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: ssh.c,v 1.294 2006/10/06 02:29:19 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland diff --git a/crypto/openssh-4/sshconnect.c b/crypto/openssh-4/sshconnect.c index a7a4e8a969..a222233d0a 100644 --- a/crypto/openssh-4/sshconnect.c +++ b/crypto/openssh-4/sshconnect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshconnect.c,v 1.199 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: sshconnect.c,v 1.200 2006/10/10 10:12:45 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -324,9 +324,11 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr, gai_strerror(gaierr)); for (attempt = 0; attempt < connection_attempts; attempt++) { - if (attempt > 0) + if (attempt > 0) { + /* Sleep a moment before retrying. */ + sleep(1); debug("Trying again..."); - + } /* * Loop through addresses for this host, and try each one in * sequence until the connection succeeds. @@ -363,9 +365,6 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr, } if (sock != -1) break; /* Successful connection. */ - - /* Sleep a moment before retrying. */ - sleep(1); } freeaddrinfo(aitop); diff --git a/crypto/openssh-4/sshconnect1.c b/crypto/openssh-4/sshconnect1.c index 90fcb344fc..fd07bbf741 100644 --- a/crypto/openssh-4/sshconnect1.c +++ b/crypto/openssh-4/sshconnect1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshconnect1.c,v 1.69 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: sshconnect1.c,v 1.70 2006/11/06 21:25:28 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -563,14 +563,20 @@ ssh_kex(char *host, struct sockaddr *hostaddr) * the first 16 bytes of the session id. */ if ((key = BN_new()) == NULL) - fatal("respond_to_rsa_challenge: BN_new failed"); - BN_set_word(key, 0); + fatal("ssh_kex: BN_new failed"); + if (BN_set_word(key, 0) == 0) + fatal("ssh_kex: BN_set_word failed"); for (i = 0; i < SSH_SESSION_KEY_LENGTH; i++) { - BN_lshift(key, key, 8); - if (i < 16) - BN_add_word(key, session_key[i] ^ session_id[i]); - else - BN_add_word(key, session_key[i]); + if (BN_lshift(key, key, 8) == 0) + fatal("ssh_kex: BN_lshift failed"); + if (i < 16) { + if (BN_add_word(key, session_key[i] ^ session_id[i]) + == 0) + fatal("ssh_kex: BN_add_word failed"); + } else { + if (BN_add_word(key, session_key[i]) == 0) + fatal("ssh_kex: BN_add_word failed"); + } } /* diff --git a/crypto/openssh-4/sshd.c b/crypto/openssh-4/sshd.c index 6159a5b6af..4aa1c98ed4 100644 --- a/crypto/openssh-4/sshd.c +++ b/crypto/openssh-4/sshd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshd.c,v 1.347 2006/08/18 09:15:20 markus Exp $ */ +/* $OpenBSD: sshd.c,v 1.348 2006/11/06 21:25:28 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -1431,13 +1431,17 @@ main(int ac, char **av) debug("sshd version %.100s", SSH_RELEASE); - /* Store privilege separation user for later use */ - if ((privsep_pw = getpwnam(SSH_PRIVSEP_USER)) == NULL) - fatal("Privilege separation user %s does not exist", - SSH_PRIVSEP_USER); - memset(privsep_pw->pw_passwd, 0, strlen(privsep_pw->pw_passwd)); - privsep_pw->pw_passwd = "*"; - privsep_pw = pwcopy(privsep_pw); + /* Store privilege separation user for later use if required. */ + if ((privsep_pw = getpwnam(SSH_PRIVSEP_USER)) == NULL) { + if (use_privsep || options.kerberos_authentication) + fatal("Privilege separation user %s does not exist", + SSH_PRIVSEP_USER); + } else { + memset(privsep_pw->pw_passwd, 0, strlen(privsep_pw->pw_passwd)); + privsep_pw = pwcopy(privsep_pw); + xfree(privsep_pw->pw_passwd); + privsep_pw->pw_passwd = xstrdup("*"); + } endpwent(); /* load private host keys */ @@ -2009,10 +2013,10 @@ do_ssh1_kex(void) * key is in the highest bits. */ if (!rsafail) { - BN_mask_bits(session_key_int, sizeof(session_key) * 8); + (void) BN_mask_bits(session_key_int, sizeof(session_key) * 8); len = BN_num_bytes(session_key_int); if (len < 0 || (u_int)len > sizeof(session_key)) { - error("do_connection: bad session key len from %s: " + error("do_ssh1_kex: bad session key len from %s: " "session_key_int %d > sizeof(session_key) %lu", get_remote_ipaddr(), len, (u_long)sizeof(session_key)); rsafail++; -- 2.11.4.GIT