summaryrefslogtreecommitdiff
path: root/sshconnect2.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-01-19 21:34:45 +0000
committerDamien Miller <djm@mindrot.org>2019-01-20 09:02:36 +1100
commited1df7226caf3a943a36d580d4d4e9275f8a61ee (patch)
treef96450c8bb2f17ee8002281e006a75de42b96112 /sshconnect2.c
parent23f22a4aaa923c61ec49a99ebaa383656e87fa40 (diff)
upstream: convert sshconnect2.c to new packet API
with & ok markus@ OpenBSD-Commit-ID: 1cb869e0d6e03539f943235641ea070cae2ebc58
Diffstat (limited to 'sshconnect2.c')
-rw-r--r--sshconnect2.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/sshconnect2.c b/sshconnect2.c
index 73ffe77a9..bd98a12a7 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect2.c,v 1.293 2019/01/19 21:31:32 djm Exp $ */ 1/* $OpenBSD: sshconnect2.c,v 1.294 2019/01/19 21:34:45 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2008 Damien Miller. All rights reserved. 4 * Copyright (c) 2008 Damien Miller. All rights reserved.
@@ -197,7 +197,7 @@ ssh_kex2(struct ssh *ssh, char *host, struct sockaddr *hostaddr, u_short port)
197 } 197 }
198 198
199 if (options.rekey_limit || options.rekey_interval) 199 if (options.rekey_limit || options.rekey_interval)
200 packet_set_rekey_limits(options.rekey_limit, 200 ssh_packet_set_rekey_limits(ssh, options.rekey_limit,
201 options.rekey_interval); 201 options.rekey_interval);
202 202
203 /* start key exchange */ 203 /* start key exchange */
@@ -510,17 +510,21 @@ input_userauth_error(int type, u_int32_t seq, struct ssh *ssh)
510int 510int
511input_userauth_banner(int type, u_int32_t seq, struct ssh *ssh) 511input_userauth_banner(int type, u_int32_t seq, struct ssh *ssh)
512{ 512{
513 char *msg, *lang; 513 char *msg = NULL, *lang = NULL;
514 u_int len; 514 size_t len;
515 int r;
515 516
516 debug3("%s", __func__); 517 debug3("%s", __func__);
517 msg = packet_get_string(&len); 518 if ((r = sshpkt_get_cstring(ssh, &msg, &len)) != 0 ||
518 lang = packet_get_string(NULL); 519 (r = sshpkt_get_cstring(ssh, &lang, NULL)) != 0)
520 goto out;
519 if (len > 0 && options.log_level >= SYSLOG_LEVEL_INFO) 521 if (len > 0 && options.log_level >= SYSLOG_LEVEL_INFO)
520 fmprintf(stderr, "%s", msg); 522 fmprintf(stderr, "%s", msg);
523 r = 0;
524 out:
521 free(msg); 525 free(msg);
522 free(lang); 526 free(lang);
523 return 0; 527 return r;
524} 528}
525 529
526/* ARGSUSED */ 530/* ARGSUSED */
@@ -1806,13 +1810,13 @@ input_userauth_info_req(int type, u_int32_t seq, struct ssh *ssh)
1806} 1810}
1807 1811
1808static int 1812static int
1809ssh_keysign(struct sshkey *key, u_char **sigp, size_t *lenp, 1813ssh_keysign(struct ssh *ssh, struct sshkey *key, u_char **sigp, size_t *lenp,
1810 const u_char *data, size_t datalen) 1814 const u_char *data, size_t datalen)
1811{ 1815{
1812 struct sshbuf *b; 1816 struct sshbuf *b;
1813 struct stat st; 1817 struct stat st;
1814 pid_t pid; 1818 pid_t pid;
1815 int i, r, to[2], from[2], status, sock = packet_get_connection_in(); 1819 int i, r, to[2], from[2], status, sock = ssh_packet_get_connection_in(ssh);
1816 u_char rversion = 0, version = 2; 1820 u_char rversion = 0, version = 2;
1817 void (*osigchld)(int); 1821 void (*osigchld)(int);
1818 1822
@@ -1986,7 +1990,7 @@ userauth_hostbased(Authctxt *authctxt)
1986 __func__, sshkey_ssh_name(private), fp); 1990 __func__, sshkey_ssh_name(private), fp);
1987 1991
1988 /* figure out a name for the client host */ 1992 /* figure out a name for the client host */
1989 if ((lname = get_local_name(packet_get_connection_in())) == NULL) { 1993 if ((lname = get_local_name(ssh_packet_get_connection_in(ssh))) == NULL) {
1990 error("%s: cannot get local ipaddr/name", __func__); 1994 error("%s: cannot get local ipaddr/name", __func__);
1991 goto out; 1995 goto out;
1992 } 1996 }
@@ -2020,9 +2024,8 @@ userauth_hostbased(Authctxt *authctxt)
2020#ifdef DEBUG_PK 2024#ifdef DEBUG_PK
2021 sshbuf_dump(b, stderr); 2025 sshbuf_dump(b, stderr);
2022#endif 2026#endif
2023 r = ssh_keysign(private, &sig, &siglen, 2027 if ((r = ssh_keysign(ssh, private, &sig, &siglen,
2024 sshbuf_ptr(b), sshbuf_len(b)); 2028 sshbuf_ptr(b), sshbuf_len(b))) != 0) {
2025 if (r != 0) {
2026 error("sign using hostkey %s %s failed", 2029 error("sign using hostkey %s %s failed",
2027 sshkey_ssh_name(private), fp); 2030 sshkey_ssh_name(private), fp);
2028 goto out; 2031 goto out;