summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-04-16 11:18:38 +1000
committerDamien Miller <djm@mindrot.org>2000-04-16 11:18:38 +1000
commit4af51306d9a51459a5bef922df1037f876ae51fe (patch)
tree09ecfc215fce82345a3259f8a0f384b9a67906f0
parent5d1705ecf9bd3216dc99a84242bcdf2e7297d307 (diff)
- OpenBSD CVS updates.
[ssh.1 ssh.c] - ssh -2 [auth.c channels.c clientloop.c packet.c packet.h serverloop.c] [session.c sshconnect.c] - check payload for (illegal) extra data [ALL] - whitespace cleanup
-rw-r--r--ChangeLog12
-rw-r--r--auth-krb4.c10
-rw-r--r--auth-passwd.c4
-rw-r--r--auth-rh-rsa.c14
-rw-r--r--auth-rhosts.c18
-rw-r--r--auth-rsa.c16
-rw-r--r--auth-skey.c18
-rw-r--r--auth.c62
-rw-r--r--authfd.c24
-rw-r--r--authfd.h22
-rw-r--r--authfile.c14
-rw-r--r--bufaux.c12
-rw-r--r--bufaux.h12
-rw-r--r--buffer.c34
-rw-r--r--canohost.c20
-rw-r--r--channels.c94
-rw-r--r--channels.h6
-rw-r--r--cipher.c34
-rw-r--r--cipher.h24
-rw-r--r--clientloop.c59
-rw-r--r--compat.c6
-rw-r--r--compress.c22
-rw-r--r--compress.h14
-rw-r--r--crc32.h14
-rw-r--r--dispatch.c78
-rw-r--r--dsa.c10
-rw-r--r--getput.h16
-rw-r--r--hostfile.c14
-rw-r--r--hostfile.h2
-rw-r--r--includes.h12
-rw-r--r--kex.c12
-rw-r--r--log-client.c14
-rw-r--r--log-server.c16
-rw-r--r--login.c20
-rw-r--r--match.c16
-rw-r--r--mpaux.c14
-rw-r--r--mpaux.h14
-rw-r--r--nchan.c6
-rw-r--r--packet.c32
-rw-r--r--packet.h29
-rw-r--r--pty.c22
-rw-r--r--pty.h14
-rw-r--r--radix.c12
-rw-r--r--readconf.c26
-rw-r--r--readconf.h22
-rw-r--r--readpass.c4
-rw-r--r--rsa.c30
-rw-r--r--rsa.h14
-rw-r--r--scp.c20
-rw-r--r--servconf.c24
-rw-r--r--servconf.h14
-rw-r--r--serverloop.c46
-rw-r--r--session.c25
-rw-r--r--ssh-agent.c10
-rw-r--r--ssh-keygen.c4
-rw-r--r--ssh.18
-rw-r--r--ssh.c42
-rw-r--r--ssh.h30
-rw-r--r--ssh2.h20
-rw-r--r--sshconnect.c56
-rw-r--r--sshd.c54
-rw-r--r--ttymodes.c10
-rw-r--r--ttymodes.h12
-rw-r--r--uidswap.c8
-rw-r--r--uidswap.h10
-rw-r--r--xmalloc.c4
-rw-r--r--xmalloc.h14
67 files changed, 779 insertions, 646 deletions
diff --git a/ChangeLog b/ChangeLog
index 643a97f00..f23250edf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,17 @@
120000415
2 - OpenBSD CVS updates.
3 [ssh.1 ssh.c]
4 - ssh -2
5 [auth.c channels.c clientloop.c packet.c packet.h serverloop.c]
6 [session.c sshconnect.c]
7 - check payload for (illegal) extra data
8 [ALL]
9 whitespace cleanup
10
120000413 1120000413
2 - INSTALL doc updates 12 - INSTALL doc updates
3 - Merged OpenBSD updates to include paths. 13 - Merged OpenBSD updates to include paths.
4 14
520000412 1520000412
6 - OpenBSD CVS updates: 16 - OpenBSD CVS updates:
7 - [channels.c] 17 - [channels.c]
diff --git a/auth-krb4.c b/auth-krb4.c
index 7e30646f8..a26842713 100644
--- a/auth-krb4.c
+++ b/auth-krb4.c
@@ -19,7 +19,7 @@ extern ServerOptions options;
19 * return 1 on success, 0 on failure, -1 if krb4 is not available 19 * return 1 on success, 0 on failure, -1 if krb4 is not available
20 */ 20 */
21 21
22int 22int
23auth_krb4_password(struct passwd * pw, const char *password) 23auth_krb4_password(struct passwd * pw, const char *password)
24{ 24{
25 AUTH_DAT adata; 25 AUTH_DAT adata;
@@ -135,7 +135,7 @@ krb4_cleanup_proc(void *ignore)
135 } 135 }
136} 136}
137 137
138int 138int
139krb4_init(uid_t uid) 139krb4_init(uid_t uid)
140{ 140{
141 static int cleanup_registered = 0; 141 static int cleanup_registered = 0;
@@ -179,7 +179,7 @@ krb4_init(uid_t uid)
179 return 0; 179 return 0;
180} 180}
181 181
182int 182int
183auth_krb4(const char *server_user, KTEXT auth, char **client) 183auth_krb4(const char *server_user, KTEXT auth, char **client)
184{ 184{
185 AUTH_DAT adat = {0}; 185 AUTH_DAT adat = {0};
@@ -252,7 +252,7 @@ auth_krb4(const char *server_user, KTEXT auth, char **client)
252#endif /* KRB4 */ 252#endif /* KRB4 */
253 253
254#ifdef AFS 254#ifdef AFS
255int 255int
256auth_kerberos_tgt(struct passwd *pw, const char *string) 256auth_kerberos_tgt(struct passwd *pw, const char *string)
257{ 257{
258 CREDENTIALS creds; 258 CREDENTIALS creds;
@@ -307,7 +307,7 @@ auth_kerberos_tgt_failure:
307 return 0; 307 return 0;
308} 308}
309 309
310int 310int
311auth_afs_token(struct passwd *pw, const char *token_string) 311auth_afs_token(struct passwd *pw, const char *token_string)
312{ 312{
313 CREDENTIALS creds; 313 CREDENTIALS creds;
diff --git a/auth-passwd.c b/auth-passwd.c
index 278212aa5..d2c2ea876 100644
--- a/auth-passwd.c
+++ b/auth-passwd.c
@@ -11,7 +11,7 @@
11 11
12#ifndef USE_PAM 12#ifndef USE_PAM
13 13
14RCSID("$Id: auth-passwd.c,v 1.16 2000/01/22 23:32:03 damien Exp $"); 14RCSID("$Id: auth-passwd.c,v 1.17 2000/04/16 01:18:39 damien Exp $");
15 15
16#include "packet.h" 16#include "packet.h"
17#include "ssh.h" 17#include "ssh.h"
@@ -33,7 +33,7 @@ RCSID("$Id: auth-passwd.c,v 1.16 2000/01/22 23:32:03 damien Exp $");
33 * Tries to authenticate the user using password. Returns true if 33 * Tries to authenticate the user using password. Returns true if
34 * authentication succeeds. 34 * authentication succeeds.
35 */ 35 */
36int 36int
37auth_password(struct passwd * pw, const char *password) 37auth_password(struct passwd * pw, const char *password)
38{ 38{
39 extern ServerOptions options; 39 extern ServerOptions options;
diff --git a/auth-rh-rsa.c b/auth-rh-rsa.c
index d3d90246c..150132fb4 100644
--- a/auth-rh-rsa.c
+++ b/auth-rh-rsa.c
@@ -1,21 +1,21 @@
1/* 1/*
2 * 2 *
3 * auth-rh-rsa.c 3 * auth-rh-rsa.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Sun May 7 03:08:06 1995 ylo 10 * Created: Sun May 7 03:08:06 1995 ylo
11 * 11 *
12 * Rhosts or /etc/hosts.equiv authentication combined with RSA host 12 * Rhosts or /etc/hosts.equiv authentication combined with RSA host
13 * authentication. 13 * authentication.
14 * 14 *
15 */ 15 */
16 16
17#include "includes.h" 17#include "includes.h"
18RCSID("$Id: auth-rh-rsa.c,v 1.9 2000/04/13 02:26:35 damien Exp $"); 18RCSID("$Id: auth-rh-rsa.c,v 1.10 2000/04/16 01:18:39 damien Exp $");
19 19
20#ifdef HAVE_OPENSSL 20#ifdef HAVE_OPENSSL
21#include <openssl/bn.h> 21#include <openssl/bn.h>
@@ -42,7 +42,7 @@ RCSID("$Id: auth-rh-rsa.c,v 1.9 2000/04/13 02:26:35 damien Exp $");
42 * its host key. Returns true if authentication succeeds. 42 * its host key. Returns true if authentication succeeds.
43 */ 43 */
44 44
45int 45int
46auth_rhosts_rsa(struct passwd *pw, const char *client_user, RSA *client_host_key) 46auth_rhosts_rsa(struct passwd *pw, const char *client_user, RSA *client_host_key)
47{ 47{
48 extern ServerOptions options; 48 extern ServerOptions options;
diff --git a/auth-rhosts.c b/auth-rhosts.c
index 318bcfefe..6a5c13e43 100644
--- a/auth-rhosts.c
+++ b/auth-rhosts.c
@@ -1,22 +1,22 @@
1/* 1/*
2 * 2 *
3 * auth-rhosts.c 3 * auth-rhosts.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Fri Mar 17 05:12:18 1995 ylo 10 * Created: Fri Mar 17 05:12:18 1995 ylo
11 * 11 *
12 * Rhosts authentication. This file contains code to check whether to admit 12 * Rhosts authentication. This file contains code to check whether to admit
13 * the login based on rhosts authentication. This file also processes 13 * the login based on rhosts authentication. This file also processes
14 * /etc/hosts.equiv. 14 * /etc/hosts.equiv.
15 * 15 *
16 */ 16 */
17 17
18#include "includes.h" 18#include "includes.h"
19RCSID("$Id: auth-rhosts.c,v 1.7 1999/12/27 12:54:55 damien Exp $"); 19RCSID("$Id: auth-rhosts.c,v 1.8 2000/04/16 01:18:39 damien Exp $");
20 20
21#include "packet.h" 21#include "packet.h"
22#include "ssh.h" 22#include "ssh.h"
@@ -30,7 +30,7 @@ RCSID("$Id: auth-rhosts.c,v 1.7 1999/12/27 12:54:55 damien Exp $");
30 * based on the file, and returns zero otherwise. 30 * based on the file, and returns zero otherwise.
31 */ 31 */
32 32
33int 33int
34check_rhosts_file(const char *filename, const char *hostname, 34check_rhosts_file(const char *filename, const char *hostname,
35 const char *ipaddr, const char *client_user, 35 const char *ipaddr, const char *client_user,
36 const char *server_user) 36 const char *server_user)
@@ -146,7 +146,7 @@ check_rhosts_file(const char *filename, const char *hostname,
146 * /etc/hosts.equiv will be considered (.rhosts and .shosts are ignored). 146 * /etc/hosts.equiv will be considered (.rhosts and .shosts are ignored).
147 */ 147 */
148 148
149int 149int
150auth_rhosts(struct passwd *pw, const char *client_user) 150auth_rhosts(struct passwd *pw, const char *client_user)
151{ 151{
152 extern ServerOptions options; 152 extern ServerOptions options;
diff --git a/auth-rsa.c b/auth-rsa.c
index fff524949..e9d61f69b 100644
--- a/auth-rsa.c
+++ b/auth-rsa.c
@@ -1,22 +1,22 @@
1/* 1/*
2 * 2 *
3 * auth-rsa.c 3 * auth-rsa.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Mon Mar 27 01:46:52 1995 ylo 10 * Created: Mon Mar 27 01:46:52 1995 ylo
11 * 11 *
12 * RSA-based authentication. This code determines whether to admit a login 12 * RSA-based authentication. This code determines whether to admit a login
13 * based on RSA authentication. This file also contains functions to check 13 * based on RSA authentication. This file also contains functions to check
14 * validity of the host key. 14 * validity of the host key.
15 * 15 *
16 */ 16 */
17 17
18#include "includes.h" 18#include "includes.h"
19RCSID("$Id: auth-rsa.c,v 1.15 2000/04/13 02:26:35 damien Exp $"); 19RCSID("$Id: auth-rsa.c,v 1.16 2000/04/16 01:18:39 damien Exp $");
20 20
21#include "rsa.h" 21#include "rsa.h"
22#include "packet.h" 22#include "packet.h"
@@ -244,7 +244,7 @@ auth_rsa(struct passwd *pw, BIGNUM *client_n)
244 debug("%.100s, line %lu: bad key syntax", 244 debug("%.100s, line %lu: bad key syntax",
245 SSH_USER_PERMITTED_KEYS, linenum); 245 SSH_USER_PERMITTED_KEYS, linenum);
246 packet_send_debug("%.100s, line %lu: bad key syntax", 246 packet_send_debug("%.100s, line %lu: bad key syntax",
247 SSH_USER_PERMITTED_KEYS, linenum); 247 SSH_USER_PERMITTED_KEYS, linenum);
248 continue; 248 continue;
249 } 249 }
250 /* cp now points to the comment part. */ 250 /* cp now points to the comment part. */
diff --git a/auth-skey.c b/auth-skey.c
index f403a1962..056efeb9b 100644
--- a/auth-skey.c
+++ b/auth-skey.c
@@ -1,7 +1,7 @@
1#include "includes.h" 1#include "includes.h"
2 2
3#ifdef SKEY 3#ifdef SKEY
4RCSID("$Id: auth-skey.c,v 1.5 1999/12/06 19:04:57 deraadt Exp $"); 4RCSID("$Id: auth-skey.c,v 1.6 2000/04/14 10:30:29 markus Exp $");
5 5
6#include "ssh.h" 6#include "ssh.h"
7#include "packet.h" 7#include "packet.h"
@@ -15,12 +15,12 @@ RCSID("$Id: auth-skey.c,v 1.5 1999/12/06 19:04:57 deraadt Exp $");
15 15
16/* from %OpenBSD: skeylogin.c,v 1.32 1999/08/16 14:46:56 millert Exp % */ 16/* from %OpenBSD: skeylogin.c,v 1.32 1999/08/16 14:46:56 millert Exp % */
17 17
18/* 18/*
19 * try skey authentication, 19 * try skey authentication,
20 * return 1 on success, 0 on failure, -1 if skey is not available 20 * return 1 on success, 0 on failure, -1 if skey is not available
21 */ 21 */
22 22
23int 23int
24auth_skey_password(struct passwd * pw, const char *password) 24auth_skey_password(struct passwd * pw, const char *password)
25{ 25{
26 if (strncasecmp(password, "s/key", 5) == 0) { 26 if (strncasecmp(password, "s/key", 5) == 0) {
@@ -53,18 +53,18 @@ auth_skey_password(struct passwd * pw, const char *password)
53 */ 53 */
54static u_int32_t 54static u_int32_t
55hash_collapse(s) 55hash_collapse(s)
56 u_char *s; 56 u_char *s;
57{ 57{
58 int len, target; 58 int len, target;
59 u_int32_t i; 59 u_int32_t i;
60 60
61 if ((strlen(s) % sizeof(u_int32_t)) == 0) 61 if ((strlen(s) % sizeof(u_int32_t)) == 0)
62 target = strlen(s); /* Multiple of 4 */ 62 target = strlen(s); /* Multiple of 4 */
63 else 63 else
64 target = strlen(s) - (strlen(s) % sizeof(u_int32_t)); 64 target = strlen(s) - (strlen(s) % sizeof(u_int32_t));
65 65
66 for (i = 0, len = 0; len < target; len += 4) 66 for (i = 0, len = 0; len < target; len += 4)
67 i ^= ROUND(s + len); 67 i ^= ROUND(s + len);
68 68
69 return i; 69 return i;
70} 70}
diff --git a/auth.c b/auth.c
index e94a86e95..4c6f32b0a 100644
--- a/auth.c
+++ b/auth.c
@@ -5,7 +5,7 @@
5 */ 5 */
6 6
7#include "includes.h" 7#include "includes.h"
8RCSID("$OpenBSD: auth.c,v 1.2 2000/04/06 08:55:22 markus Exp $"); 8RCSID("$OpenBSD: auth.c,v 1.4 2000/04/14 10:30:29 markus Exp $");
9 9
10#include "xmalloc.h" 10#include "xmalloc.h"
11#include "rsa.h" 11#include "rsa.h"
@@ -36,9 +36,9 @@ extern char *forced_command;
36 * DenyUsers or user's primary group is listed in DenyGroups, false will 36 * DenyUsers or user's primary group is listed in DenyGroups, false will
37 * be returned. If AllowUsers isn't empty and user isn't listed there, or 37 * be returned. If AllowUsers isn't empty and user isn't listed there, or
38 * if AllowGroups isn't empty and user isn't listed there, false will be 38 * if AllowGroups isn't empty and user isn't listed there, false will be
39 * returned. 39 * returned.
40 * If the user's shell is not executable, false will be returned. 40 * If the user's shell is not executable, false will be returned.
41 * Otherwise true is returned. 41 * Otherwise true is returned.
42 */ 42 */
43static int 43static int
44allowed_user(struct passwd * pw) 44allowed_user(struct passwd * pw)
@@ -201,10 +201,10 @@ do_fake_authloop1(char *user)
201 packet_write_wait(); 201 packet_write_wait();
202 continue; 202 continue;
203 } else if (type == SSH_CMSG_AUTH_PASSWORD && 203 } else if (type == SSH_CMSG_AUTH_PASSWORD &&
204 options.password_authentication && 204 options.password_authentication &&
205 (password = packet_get_string(&dlen)) != NULL && 205 (password = packet_get_string(&dlen)) != NULL &&
206 dlen == 5 && 206 dlen == 5 &&
207 strncasecmp(password, "s/key", 5) == 0 ) { 207 strncasecmp(password, "s/key", 5) == 0 ) {
208 packet_send_debug(skeyinfo); 208 packet_send_debug(skeyinfo);
209 } 209 }
210 if (password != NULL) 210 if (password != NULL)
@@ -457,20 +457,20 @@ do_authloop(struct passwd * pw)
457 break; 457 break;
458 } 458 }
459 459
460 /* 460 /*
461 * Check if the user is logging in as root and root logins 461 * Check if the user is logging in as root and root logins
462 * are disallowed. 462 * are disallowed.
463 * Note that root login is allowed for forced commands. 463 * Note that root login is allowed for forced commands.
464 */ 464 */
465 if (authenticated && pw->pw_uid == 0 && !options.permit_root_login) { 465 if (authenticated && pw->pw_uid == 0 && !options.permit_root_login) {
466 if (forced_command) { 466 if (forced_command) {
467 log("Root login accepted for forced command."); 467 log("Root login accepted for forced command.");
468 } else { 468 } else {
469 authenticated = 0; 469 authenticated = 0;
470 log("ROOT LOGIN REFUSED FROM %.200s", 470 log("ROOT LOGIN REFUSED FROM %.200s",
471 get_canonical_hostname()); 471 get_canonical_hostname());
472 } 472 }
473 } 473 }
474 474
475 /* Raise logging level */ 475 /* Raise logging level */
476 if (authenticated || 476 if (authenticated ||
@@ -685,6 +685,7 @@ input_service_request(int type, int plen)
685 unsigned int len; 685 unsigned int len;
686 int accept = 0; 686 int accept = 0;
687 char *service = packet_get_string(&len); 687 char *service = packet_get_string(&len);
688 packet_done();
688 689
689 if (strcmp(service, "ssh-userauth") == 0) { 690 if (strcmp(service, "ssh-userauth") == 0) {
690 if (!userauth_success) { 691 if (!userauth_success) {
@@ -727,6 +728,7 @@ input_userauth_request(int type, int plen)
727 pw = auth_set_user(user, service); 728 pw = auth_set_user(user, service);
728 if (pw && strcmp(service, "ssh-connection")==0) { 729 if (pw && strcmp(service, "ssh-connection")==0) {
729 if (strcmp(method, "none") == 0 && try == 1) { 730 if (strcmp(method, "none") == 0 && try == 1) {
731 packet_done();
730#ifdef USE_PAM 732#ifdef USE_PAM
731 /* Do PAM auth with password */ 733 /* Do PAM auth with password */
732 authenticated = auth_pam_password(pw, ""); 734 authenticated = auth_pam_password(pw, "");
@@ -740,6 +742,7 @@ input_userauth_request(int type, int plen)
740 if (c) 742 if (c)
741 debug("password change not supported"); 743 debug("password change not supported");
742 password = packet_get_string(&len); 744 password = packet_get_string(&len);
745 packet_done();
743#ifdef USE_PAM 746#ifdef USE_PAM
744 /* Do PAM auth with password */ 747 /* Do PAM auth with password */
745 authenticated = auth_pam_password(pw, password); 748 authenticated = auth_pam_password(pw, password);
@@ -751,11 +754,19 @@ input_userauth_request(int type, int plen)
751 xfree(password); 754 xfree(password);
752 } else if (strcmp(method, "publickey") == 0) { 755 } else if (strcmp(method, "publickey") == 0) {
753 /* XXX TODO */ 756 /* XXX TODO */
754 char *pkalg; 757 char *pkalg, *pkblob, *sig;
755 char *pkblob; 758 int have_sig = packet_get_char();
756 c = packet_get_char();
757 pkalg = packet_get_string(&len); 759 pkalg = packet_get_string(&len);
758 pkblob = packet_get_string(&len); 760 pkblob = packet_get_string(&len);
761 if (have_sig) {
762 sig = packet_get_string(&len);
763 /* test for correct signature */
764 packet_done();
765 xfree(sig);
766 } else {
767 packet_done();
768 /* test whether pkalg/pkblob are acceptable */
769 }
759 xfree(pkalg); 770 xfree(pkalg);
760 xfree(pkblob); 771 xfree(pkblob);
761 } 772 }
@@ -764,7 +775,6 @@ input_userauth_request(int type, int plen)
764 if (authenticated) { 775 if (authenticated) {
765 /* turn off userauth */ 776 /* turn off userauth */
766 dispatch_set(SSH2_MSG_USERAUTH_REQUEST, &protocol_error); 777 dispatch_set(SSH2_MSG_USERAUTH_REQUEST, &protocol_error);
767 /* success! */
768 packet_start(SSH2_MSG_USERAUTH_SUCCESS); 778 packet_start(SSH2_MSG_USERAUTH_SUCCESS);
769 packet_send(); 779 packet_send();
770 packet_write_wait(); 780 packet_write_wait();
@@ -782,7 +792,7 @@ input_userauth_request(int type, int plen)
782 xfree(user); 792 xfree(user);
783 xfree(method); 793 xfree(method);
784} 794}
785void 795void
786do_authentication2() 796do_authentication2()
787{ 797{
788 dispatch_init(&protocol_error); 798 dispatch_init(&protocol_error);
diff --git a/authfd.c b/authfd.c
index 80af9529a..d920b1f66 100644
--- a/authfd.c
+++ b/authfd.c
@@ -1,20 +1,20 @@
1/* 1/*
2 * 2 *
3 * authfd.c 3 * authfd.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Wed Mar 29 01:30:28 1995 ylo 10 * Created: Wed Mar 29 01:30:28 1995 ylo
11 * 11 *
12 * Functions for connecting the local authentication agent. 12 * Functions for connecting the local authentication agent.
13 * 13 *
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$Id: authfd.c,v 1.11 2000/04/13 02:26:35 damien Exp $"); 17RCSID("$Id: authfd.c,v 1.12 2000/04/16 01:18:40 damien Exp $");
18 18
19#include "ssh.h" 19#include "ssh.h"
20#include "rsa.h" 20#include "rsa.h"
@@ -69,7 +69,7 @@ ssh_get_authentication_socket()
69 * ssh_get_authentication_socket(). 69 * ssh_get_authentication_socket().
70 */ 70 */
71 71
72void 72void
73ssh_close_authentication_socket(int sock) 73ssh_close_authentication_socket(int sock)
74{ 74{
75 if (getenv(SSH_AUTHSOCKET_ENV_NAME)) 75 if (getenv(SSH_AUTHSOCKET_ENV_NAME))
@@ -113,7 +113,7 @@ ssh_get_authentication_connection()
113 * memory. 113 * memory.
114 */ 114 */
115 115
116void 116void
117ssh_close_authentication_connection(AuthenticationConnection *ac) 117ssh_close_authentication_connection(AuthenticationConnection *ac)
118{ 118{
119 buffer_free(&ac->packet); 119 buffer_free(&ac->packet);
@@ -343,7 +343,7 @@ error_cleanup:
343 * be used by normal applications. 343 * be used by normal applications.
344 */ 344 */
345 345
346int 346int
347ssh_add_identity(AuthenticationConnection *auth, 347ssh_add_identity(AuthenticationConnection *auth,
348 RSA * key, const char *comment) 348 RSA * key, const char *comment)
349{ 349{
@@ -431,7 +431,7 @@ error_cleanup:
431 * meant to be used by normal applications. 431 * meant to be used by normal applications.
432 */ 432 */
433 433
434int 434int
435ssh_remove_identity(AuthenticationConnection *auth, RSA *key) 435ssh_remove_identity(AuthenticationConnection *auth, RSA *key)
436{ 436{
437 Buffer buffer; 437 Buffer buffer;
@@ -514,7 +514,7 @@ error_cleanup:
514 * by normal applications. 514 * by normal applications.
515 */ 515 */
516 516
517int 517int
518ssh_remove_all_identities(AuthenticationConnection *auth) 518ssh_remove_all_identities(AuthenticationConnection *auth)
519{ 519{
520 Buffer buffer; 520 Buffer buffer;
diff --git a/authfd.h b/authfd.h
index 01cfd93a5..420f592bb 100644
--- a/authfd.h
+++ b/authfd.h
@@ -1,19 +1,19 @@
1/* 1/*
2 * 2 *
3 * authfd.h 3 * authfd.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Wed Mar 29 01:17:41 1995 ylo 10 * Created: Wed Mar 29 01:17:41 1995 ylo
11 * 11 *
12 * Functions to interface with the SSH_AUTHENTICATION_FD socket. 12 * Functions to interface with the SSH_AUTHENTICATION_FD socket.
13 * 13 *
14 */ 14 */
15 15
16/* RCSID("$Id: authfd.h,v 1.4 1999/11/25 00:54:58 damien Exp $"); */ 16/* RCSID("$Id: authfd.h,v 1.5 2000/04/16 01:18:40 damien Exp $"); */
17 17
18#ifndef AUTHFD_H 18#ifndef AUTHFD_H
19#define AUTHFD_H 19#define AUTHFD_H
@@ -67,7 +67,7 @@ void ssh_close_authentication_connection(AuthenticationConnection * ac);
67 * integers before the call, and free the comment after a successful call 67 * integers before the call, and free the comment after a successful call
68 * (before calling ssh_get_next_identity). 68 * (before calling ssh_get_next_identity).
69 */ 69 */
70int 70int
71ssh_get_first_identity(AuthenticationConnection * connection, 71ssh_get_first_identity(AuthenticationConnection * connection,
72 BIGNUM * e, BIGNUM * n, char **comment); 72 BIGNUM * e, BIGNUM * n, char **comment);
73 73
@@ -77,13 +77,13 @@ ssh_get_first_identity(AuthenticationConnection * connection,
77 * function. This returns 0 if there are no more identities. The caller 77 * function. This returns 0 if there are no more identities. The caller
78 * must free comment after a successful return. 78 * must free comment after a successful return.
79 */ 79 */
80int 80int
81ssh_get_next_identity(AuthenticationConnection * connection, 81ssh_get_next_identity(AuthenticationConnection * connection,
82 BIGNUM * e, BIGNUM * n, char **comment); 82 BIGNUM * e, BIGNUM * n, char **comment);
83 83
84/* Requests the agent to decrypt the given challenge. Returns true if 84/* Requests the agent to decrypt the given challenge. Returns true if
85 the agent claims it was able to decrypt it. */ 85 the agent claims it was able to decrypt it. */
86int 86int
87ssh_decrypt_challenge(AuthenticationConnection * auth, 87ssh_decrypt_challenge(AuthenticationConnection * auth,
88 BIGNUM * e, BIGNUM * n, BIGNUM * challenge, 88 BIGNUM * e, BIGNUM * n, BIGNUM * challenge,
89 unsigned char session_id[16], 89 unsigned char session_id[16],
@@ -95,7 +95,7 @@ ssh_decrypt_challenge(AuthenticationConnection * auth,
95 * be used by normal applications. This returns true if the identity was 95 * be used by normal applications. This returns true if the identity was
96 * successfully added. 96 * successfully added.
97 */ 97 */
98int 98int
99ssh_add_identity(AuthenticationConnection * connection, RSA * key, 99ssh_add_identity(AuthenticationConnection * connection, RSA * key,
100 const char *comment); 100 const char *comment);
101 101
diff --git a/authfile.c b/authfile.c
index 6113ddd87..d7912d0da 100644
--- a/authfile.c
+++ b/authfile.c
@@ -1,21 +1,21 @@
1/* 1/*
2 * 2 *
3 * authfile.c 3 * authfile.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Mon Mar 27 03:52:05 1995 ylo 10 * Created: Mon Mar 27 03:52:05 1995 ylo
11 * 11 *
12 * This file contains functions for reading and writing identity files, and 12 * This file contains functions for reading and writing identity files, and
13 * for reading the passphrase from the user. 13 * for reading the passphrase from the user.
14 * 14 *
15 */ 15 */
16 16
17#include "includes.h" 17#include "includes.h"
18RCSID("$Id: authfile.c,v 1.9 2000/04/13 02:26:36 damien Exp $"); 18RCSID("$Id: authfile.c,v 1.10 2000/04/16 01:18:40 damien Exp $");
19 19
20#ifdef HAVE_OPENSSL 20#ifdef HAVE_OPENSSL
21#include <openssl/bn.h> 21#include <openssl/bn.h>
diff --git a/bufaux.c b/bufaux.c
index 7ebc2aa62..b4d52270a 100644
--- a/bufaux.c
+++ b/bufaux.c
@@ -1,14 +1,14 @@
1/* 1/*
2 * 2 *
3 * bufaux.c 3 * bufaux.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Wed Mar 29 02:24:47 1995 ylo 10 * Created: Wed Mar 29 02:24:47 1995 ylo
11 * 11 *
12 * Auxiliary functions for storing and retrieving various data types to/from 12 * Auxiliary functions for storing and retrieving various data types to/from
13 * Buffers. 13 * Buffers.
14 * 14 *
@@ -17,7 +17,7 @@
17 */ 17 */
18 18
19#include "includes.h" 19#include "includes.h"
20RCSID("$Id: bufaux.c,v 1.10 2000/04/13 02:26:36 damien Exp $"); 20RCSID("$Id: bufaux.c,v 1.11 2000/04/16 01:18:40 damien Exp $");
21 21
22#include "ssh.h" 22#include "ssh.h"
23 23
diff --git a/bufaux.h b/bufaux.h
index b22e98bd4..80bad6ea7 100644
--- a/bufaux.h
+++ b/bufaux.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * 2 *
3 * bufaux.h 3 * bufaux.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Wed Mar 29 02:18:23 1995 ylo 10 * Created: Wed Mar 29 02:18:23 1995 ylo
11 * 11 *
12 */ 12 */
13 13
14/* RCSID("$Id: bufaux.h,v 1.4 2000/04/01 01:09:23 damien Exp $"); */ 14/* RCSID("$Id: bufaux.h,v 1.5 2000/04/16 01:18:40 damien Exp $"); */
15 15
16#ifndef BUFAUX_H 16#ifndef BUFAUX_H
17#define BUFAUX_H 17#define BUFAUX_H
diff --git a/buffer.c b/buffer.c
index 48ae96a42..83a63e6f0 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1,20 +1,20 @@
1/* 1/*
2 * 2 *
3 * buffer.c 3 * buffer.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Sat Mar 18 04:15:33 1995 ylo 10 * Created: Sat Mar 18 04:15:33 1995 ylo
11 * 11 *
12 * Functions for manipulating fifo buffers (that can grow if needed). 12 * Functions for manipulating fifo buffers (that can grow if needed).
13 * 13 *
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$Id: buffer.c,v 1.4 2000/04/13 02:26:36 damien Exp $"); 17RCSID("$Id: buffer.c,v 1.5 2000/04/16 01:18:40 damien Exp $");
18 18
19#include "xmalloc.h" 19#include "xmalloc.h"
20#include "buffer.h" 20#include "buffer.h"
@@ -22,7 +22,7 @@ RCSID("$Id: buffer.c,v 1.4 2000/04/13 02:26:36 damien Exp $");
22 22
23/* Initializes the buffer structure. */ 23/* Initializes the buffer structure. */
24 24
25void 25void
26buffer_init(Buffer *buffer) 26buffer_init(Buffer *buffer)
27{ 27{
28 buffer->alloc = 4096; 28 buffer->alloc = 4096;
@@ -33,7 +33,7 @@ buffer_init(Buffer *buffer)
33 33
34/* Frees any memory used for the buffer. */ 34/* Frees any memory used for the buffer. */
35 35
36void 36void
37buffer_free(Buffer *buffer) 37buffer_free(Buffer *buffer)
38{ 38{
39 memset(buffer->buf, 0, buffer->alloc); 39 memset(buffer->buf, 0, buffer->alloc);
@@ -45,7 +45,7 @@ buffer_free(Buffer *buffer)
45 * zero the memory. 45 * zero the memory.
46 */ 46 */
47 47
48void 48void
49buffer_clear(Buffer *buffer) 49buffer_clear(Buffer *buffer)
50{ 50{
51 buffer->offset = 0; 51 buffer->offset = 0;
@@ -54,7 +54,7 @@ buffer_clear(Buffer *buffer)
54 54
55/* Appends data to the buffer, expanding it if necessary. */ 55/* Appends data to the buffer, expanding it if necessary. */
56 56
57void 57void
58buffer_append(Buffer *buffer, const char *data, unsigned int len) 58buffer_append(Buffer *buffer, const char *data, unsigned int len)
59{ 59{
60 char *cp; 60 char *cp;
@@ -68,7 +68,7 @@ buffer_append(Buffer *buffer, const char *data, unsigned int len)
68 * to the allocated region. 68 * to the allocated region.
69 */ 69 */
70 70
71void 71void
72buffer_append_space(Buffer *buffer, char **datap, unsigned int len) 72buffer_append_space(Buffer *buffer, char **datap, unsigned int len)
73{ 73{
74 /* If the buffer is empty, start using it from the beginning. */ 74 /* If the buffer is empty, start using it from the beginning. */
@@ -102,7 +102,7 @@ restart:
102 102
103/* Returns the number of bytes of data in the buffer. */ 103/* Returns the number of bytes of data in the buffer. */
104 104
105unsigned int 105unsigned int
106buffer_len(Buffer *buffer) 106buffer_len(Buffer *buffer)
107{ 107{
108 return buffer->end - buffer->offset; 108 return buffer->end - buffer->offset;
@@ -110,7 +110,7 @@ buffer_len(Buffer *buffer)
110 110
111/* Gets data from the beginning of the buffer. */ 111/* Gets data from the beginning of the buffer. */
112 112
113void 113void
114buffer_get(Buffer *buffer, char *buf, unsigned int len) 114buffer_get(Buffer *buffer, char *buf, unsigned int len)
115{ 115{
116 if (len > buffer->end - buffer->offset) 116 if (len > buffer->end - buffer->offset)
@@ -121,7 +121,7 @@ buffer_get(Buffer *buffer, char *buf, unsigned int len)
121 121
122/* Consumes the given number of bytes from the beginning of the buffer. */ 122/* Consumes the given number of bytes from the beginning of the buffer. */
123 123
124void 124void
125buffer_consume(Buffer *buffer, unsigned int bytes) 125buffer_consume(Buffer *buffer, unsigned int bytes)
126{ 126{
127 if (bytes > buffer->end - buffer->offset) 127 if (bytes > buffer->end - buffer->offset)
@@ -131,7 +131,7 @@ buffer_consume(Buffer *buffer, unsigned int bytes)
131 131
132/* Consumes the given number of bytes from the end of the buffer. */ 132/* Consumes the given number of bytes from the end of the buffer. */
133 133
134void 134void
135buffer_consume_end(Buffer *buffer, unsigned int bytes) 135buffer_consume_end(Buffer *buffer, unsigned int bytes)
136{ 136{
137 if (bytes > buffer->end - buffer->offset) 137 if (bytes > buffer->end - buffer->offset)
@@ -149,7 +149,7 @@ buffer_ptr(Buffer *buffer)
149 149
150/* Dumps the contents of the buffer to stderr. */ 150/* Dumps the contents of the buffer to stderr. */
151 151
152void 152void
153buffer_dump(Buffer *buffer) 153buffer_dump(Buffer *buffer)
154{ 154{
155 int i; 155 int i;
diff --git a/canohost.c b/canohost.c
index a11d66392..1b5790929 100644
--- a/canohost.c
+++ b/canohost.c
@@ -1,20 +1,20 @@
1/* 1/*
2 * 2 *
3 * canohost.c 3 * canohost.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Sun Jul 2 17:52:22 1995 ylo 10 * Created: Sun Jul 2 17:52:22 1995 ylo
11 * 11 *
12 * Functions for returning the canonical host name of the remote site. 12 * Functions for returning the canonical host name of the remote site.
13 * 13 *
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$Id: canohost.c,v 1.8 2000/03/11 09:45:41 damien Exp $"); 17RCSID("$Id: canohost.c,v 1.9 2000/04/16 01:18:40 damien Exp $");
18 18
19#include "packet.h" 19#include "packet.h"
20#include "xmalloc.h" 20#include "xmalloc.h"
@@ -265,7 +265,7 @@ get_sock_port(int sock, int local)
265 265
266/* Returns remote/local port number for the current connection. */ 266/* Returns remote/local port number for the current connection. */
267 267
268int 268int
269get_port(int local) 269get_port(int local)
270{ 270{
271 /* 271 /*
@@ -279,13 +279,13 @@ get_port(int local)
279 return get_sock_port(packet_get_connection_in(), local); 279 return get_sock_port(packet_get_connection_in(), local);
280} 280}
281 281
282int 282int
283get_peer_port(int sock) 283get_peer_port(int sock)
284{ 284{
285 return get_sock_port(sock, 0); 285 return get_sock_port(sock, 0);
286} 286}
287 287
288int 288int
289get_remote_port() 289get_remote_port()
290{ 290{
291 return get_port(0); 291 return get_port(0);
diff --git a/channels.c b/channels.c
index 957b4a428..5f3b0d113 100644
--- a/channels.c
+++ b/channels.c
@@ -1,23 +1,23 @@
1/* 1/*
2 * 2 *
3 * channels.c 3 * channels.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Fri Mar 24 16:35:24 1995 ylo 10 * Created: Fri Mar 24 16:35:24 1995 ylo
11 * 11 *
12 * This file contains functions for generic socket connection forwarding. 12 * This file contains functions for generic socket connection forwarding.
13 * There is also code for initiating connection forwarding for X11 connections, 13 * There is also code for initiating connection forwarding for X11 connections,
14 * arbitrary tcp/ip connections, and the authentication agent connection. 14 * arbitrary tcp/ip connections, and the authentication agent connection.
15 * 15 *
16 * SSH2 support added by Markus Friedl. 16 * SSH2 support added by Markus Friedl.
17 */ 17 */
18 18
19#include "includes.h" 19#include "includes.h"
20RCSID("$Id: channels.c,v 1.24 2000/04/12 10:17:38 damien Exp $"); 20RCSID("$Id: channels.c,v 1.25 2000/04/16 01:18:41 damien Exp $");
21 21
22#include "ssh.h" 22#include "ssh.h"
23#include "packet.h" 23#include "packet.h"
@@ -109,7 +109,7 @@ static int have_hostname_in_open = 0;
109 109
110/* Sets specific protocol options. */ 110/* Sets specific protocol options. */
111 111
112void 112void
113channel_set_options(int hostname_in_open) 113channel_set_options(int hostname_in_open)
114{ 114{
115 have_hostname_in_open = hostname_in_open; 115 have_hostname_in_open = hostname_in_open;
@@ -121,7 +121,7 @@ channel_set_options(int hostname_in_open)
121 * and the server has no way to know but to trust the client anyway. 121 * and the server has no way to know but to trust the client anyway.
122 */ 122 */
123 123
124void 124void
125channel_permit_all_opens() 125channel_permit_all_opens()
126{ 126{
127 all_opens_permitted = 1; 127 all_opens_permitted = 1;
@@ -150,7 +150,7 @@ channel_lookup(int id)
150 * remote_name to be freed. 150 * remote_name to be freed.
151 */ 151 */
152 152
153int 153int
154channel_new(char *ctype, int type, int rfd, int wfd, int efd, 154channel_new(char *ctype, int type, int rfd, int wfd, int efd,
155 int window, int maxpack, int extended_usage, char *remote_name) 155 int window, int maxpack, int extended_usage, char *remote_name)
156{ 156{
@@ -226,7 +226,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
226 debug("channel %d: new [%s]", found, remote_name); 226 debug("channel %d: new [%s]", found, remote_name);
227 return found; 227 return found;
228} 228}
229int 229int
230channel_allocate(int type, int sock, char *remote_name) 230channel_allocate(int type, int sock, char *remote_name)
231{ 231{
232 return channel_new("", type, sock, sock, -1, 0, 0, 0, remote_name); 232 return channel_new("", type, sock, sock, -1, 0, 0, 0, remote_name);
@@ -234,7 +234,7 @@ channel_allocate(int type, int sock, char *remote_name)
234 234
235/* Free the channel and close its socket. */ 235/* Free the channel and close its socket. */
236 236
237void 237void
238channel_free(int id) 238channel_free(int id)
239{ 239{
240 Channel *c = channel_lookup(id); 240 Channel *c = channel_lookup(id);
@@ -361,7 +361,7 @@ channel_pre_output_draining(Channel *c, fd_set * readset, fd_set * writeset)
361{ 361{
362 if (buffer_len(&c->output) == 0) 362 if (buffer_len(&c->output) == 0)
363 channel_free(c->self); 363 channel_free(c->self);
364 else 364 else
365 FD_SET(c->sock, writeset); 365 FD_SET(c->sock, writeset);
366} 366}
367 367
@@ -540,8 +540,10 @@ channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset)
540 packet_put_int(newch); 540 packet_put_int(newch);
541 packet_put_int(c->local_window_max); 541 packet_put_int(c->local_window_max);
542 packet_put_int(c->local_maxpacket); 542 packet_put_int(c->local_maxpacket);
543 /* target host and port */
543 packet_put_string(c->path, strlen(c->path)); 544 packet_put_string(c->path, strlen(c->path));
544 packet_put_int(c->host_port); 545 packet_put_int(c->host_port);
546 /* originator host and port */
545 packet_put_cstring(remote_hostname); 547 packet_put_cstring(remote_hostname);
546 packet_put_int(remote_port); 548 packet_put_int(remote_port);
547 packet_send(); 549 packet_send();
@@ -782,7 +784,7 @@ channel_handler_init(void)
782 channel_handler_init_15(); 784 channel_handler_init_15();
783} 785}
784 786
785void 787void
786channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset) 788channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset)
787{ 789{
788 static int did_init = 0; 790 static int did_init = 0;
@@ -804,13 +806,13 @@ channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset)
804 } 806 }
805} 807}
806 808
807void 809void
808channel_prepare_select(fd_set * readset, fd_set * writeset) 810channel_prepare_select(fd_set * readset, fd_set * writeset)
809{ 811{
810 channel_handler(channel_pre, readset, writeset); 812 channel_handler(channel_pre, readset, writeset);
811} 813}
812 814
813void 815void
814channel_after_select(fd_set * readset, fd_set * writeset) 816channel_after_select(fd_set * readset, fd_set * writeset)
815{ 817{
816 channel_handler(channel_post, readset, writeset); 818 channel_handler(channel_post, readset, writeset);
@@ -818,7 +820,7 @@ channel_after_select(fd_set * readset, fd_set * writeset)
818 820
819/* If there is data to send to the connection, send some of it now. */ 821/* If there is data to send to the connection, send some of it now. */
820 822
821void 823void
822channel_output_poll() 824channel_output_poll()
823{ 825{
824 int len, i; 826 int len, i;
@@ -909,7 +911,7 @@ channel_output_poll()
909 * still there. 911 * still there.
910 */ 912 */
911 913
912void 914void
913channel_input_data(int type, int plen) 915channel_input_data(int type, int plen)
914{ 916{
915 int id; 917 int id;
@@ -934,6 +936,7 @@ channel_input_data(int type, int plen)
934 936
935 /* Get the data. */ 937 /* Get the data. */
936 data = packet_get_string(&data_len); 938 data = packet_get_string(&data_len);
939 packet_done();
937 940
938 if (compat20){ 941 if (compat20){
939 if (data_len > c->local_maxpacket) { 942 if (data_len > c->local_maxpacket) {
@@ -953,7 +956,7 @@ channel_input_data(int type, int plen)
953 buffer_append(&c->output, data, data_len); 956 buffer_append(&c->output, data, data_len);
954 xfree(data); 957 xfree(data);
955} 958}
956void 959void
957channel_input_extended_data(int type, int plen) 960channel_input_extended_data(int type, int plen)
958{ 961{
959 int id; 962 int id;
@@ -980,6 +983,7 @@ channel_input_extended_data(int type, int plen)
980 return; 983 return;
981 } 984 }
982 data = packet_get_string(&data_len); 985 data = packet_get_string(&data_len);
986 packet_done();
983 if (data_len > c->local_window) { 987 if (data_len > c->local_window) {
984 log("channel %d: rcvd too much extended_data %d, win %d", 988 log("channel %d: rcvd too much extended_data %d, win %d",
985 c->self, data_len, c->local_window); 989 c->self, data_len, c->local_window);
@@ -998,7 +1002,7 @@ channel_input_extended_data(int type, int plen)
998 * more channel is overfull. 1002 * more channel is overfull.
999 */ 1003 */
1000 1004
1001int 1005int
1002channel_not_very_much_buffered_data() 1006channel_not_very_much_buffered_data()
1003{ 1007{
1004 unsigned int i; 1008 unsigned int i;
@@ -1022,7 +1026,7 @@ channel_not_very_much_buffered_data()
1022 return 1; 1026 return 1;
1023} 1027}
1024 1028
1025void 1029void
1026channel_input_ieof(int type, int plen) 1030channel_input_ieof(int type, int plen)
1027{ 1031{
1028 int id; 1032 int id;
@@ -1037,7 +1041,7 @@ channel_input_ieof(int type, int plen)
1037 chan_rcvd_ieof(c); 1041 chan_rcvd_ieof(c);
1038} 1042}
1039 1043
1040void 1044void
1041channel_input_close(int type, int plen) 1045channel_input_close(int type, int plen)
1042{ 1046{
1043 int id; 1047 int id;
@@ -1076,7 +1080,7 @@ channel_input_close(int type, int plen)
1076} 1080}
1077 1081
1078/* proto version 1.5 overloads CLOSE_CONFIRMATION with OCLOSE */ 1082/* proto version 1.5 overloads CLOSE_CONFIRMATION with OCLOSE */
1079void 1083void
1080channel_input_oclose(int type, int plen) 1084channel_input_oclose(int type, int plen)
1081{ 1085{
1082 int id = packet_get_int(); 1086 int id = packet_get_int();
@@ -1087,12 +1091,13 @@ channel_input_oclose(int type, int plen)
1087 chan_rcvd_oclose(c); 1091 chan_rcvd_oclose(c);
1088} 1092}
1089 1093
1090void 1094void
1091channel_input_close_confirmation(int type, int plen) 1095channel_input_close_confirmation(int type, int plen)
1092{ 1096{
1093 int id = packet_get_int(); 1097 int id = packet_get_int();
1094 Channel *c = channel_lookup(id); 1098 Channel *c = channel_lookup(id);
1095 1099
1100 packet_done();
1096 if (c == NULL) 1101 if (c == NULL)
1097 packet_disconnect("Received close confirmation for " 1102 packet_disconnect("Received close confirmation for "
1098 "out-of-range channel %d.", id); 1103 "out-of-range channel %d.", id);
@@ -1102,7 +1107,7 @@ channel_input_close_confirmation(int type, int plen)
1102 channel_free(c->self); 1107 channel_free(c->self);
1103} 1108}
1104 1109
1105void 1110void
1106channel_input_open_confirmation(int type, int plen) 1111channel_input_open_confirmation(int type, int plen)
1107{ 1112{
1108 int id, remote_id; 1113 int id, remote_id;
@@ -1125,6 +1130,7 @@ channel_input_open_confirmation(int type, int plen)
1125 if (compat20) { 1130 if (compat20) {
1126 c->remote_window = packet_get_int(); 1131 c->remote_window = packet_get_int();
1127 c->remote_maxpacket = packet_get_int(); 1132 c->remote_maxpacket = packet_get_int();
1133 packet_done();
1128 if (c->cb_fn != NULL && c->cb_event == type) { 1134 if (c->cb_fn != NULL && c->cb_event == type) {
1129 debug("callback start"); 1135 debug("callback start");
1130 c->cb_fn(c->self, c->cb_arg); 1136 c->cb_fn(c->self, c->cb_arg);
@@ -1135,7 +1141,7 @@ channel_input_open_confirmation(int type, int plen)
1135 } 1141 }
1136} 1142}
1137 1143
1138void 1144void
1139channel_input_open_failure(int type, int plen) 1145channel_input_open_failure(int type, int plen)
1140{ 1146{
1141 int id; 1147 int id;
@@ -1153,8 +1159,11 @@ channel_input_open_failure(int type, int plen)
1153 if (compat20) { 1159 if (compat20) {
1154 int reason = packet_get_int(); 1160 int reason = packet_get_int();
1155 char *msg = packet_get_string(NULL); 1161 char *msg = packet_get_string(NULL);
1162 char *lang = packet_get_string(NULL);
1156 log("channel_open_failure: %d: reason %d: %s", id, reason, msg); 1163 log("channel_open_failure: %d: reason %d: %s", id, reason, msg);
1164 packet_done();
1157 xfree(msg); 1165 xfree(msg);
1166 xfree(lang);
1158 } 1167 }
1159 /* Free the channel. This will also close the socket. */ 1168 /* Free the channel. This will also close the socket. */
1160 channel_free(id); 1169 channel_free(id);
@@ -1185,7 +1194,7 @@ debug("cb_fn %p cb_event %d", c->cb_fn , c->cb_event);
1185 } 1194 }
1186} 1195}
1187 1196
1188void 1197void
1189channel_input_window_adjust(int type, int plen) 1198channel_input_window_adjust(int type, int plen)
1190{ 1199{
1191 Channel *c; 1200 Channel *c;
@@ -1204,6 +1213,7 @@ channel_input_window_adjust(int type, int plen)
1204 return; 1213 return;
1205 } 1214 }
1206 adjust = packet_get_int(); 1215 adjust = packet_get_int();
1216 packet_done();
1207 debug("channel %d: rcvd adjust %d", id, adjust); 1217 debug("channel %d: rcvd adjust %d", id, adjust);
1208 c->remote_window += adjust; 1218 c->remote_window += adjust;
1209} 1219}
@@ -1213,7 +1223,7 @@ channel_input_window_adjust(int type, int plen)
1213 * might have. 1223 * might have.
1214 */ 1224 */
1215 1225
1216void 1226void
1217channel_stop_listening() 1227channel_stop_listening()
1218{ 1228{
1219 int i; 1229 int i;
@@ -1240,7 +1250,7 @@ channel_stop_listening()
1240 * descriptors after a fork. 1250 * descriptors after a fork.
1241 */ 1251 */
1242 1252
1243void 1253void
1244channel_close_all() 1254channel_close_all()
1245{ 1255{
1246 int i; 1256 int i;
@@ -1252,7 +1262,7 @@ channel_close_all()
1252 1262
1253/* Returns the maximum file descriptor number used by the channels. */ 1263/* Returns the maximum file descriptor number used by the channels. */
1254 1264
1255int 1265int
1256channel_max_fd() 1266channel_max_fd()
1257{ 1267{
1258 return channel_max_fd_value; 1268 return channel_max_fd_value;
@@ -1260,7 +1270,7 @@ channel_max_fd()
1260 1270
1261/* Returns true if any channel is still open. */ 1271/* Returns true if any channel is still open. */
1262 1272
1263int 1273int
1264channel_still_open() 1274channel_still_open()
1265{ 1275{
1266 unsigned int i; 1276 unsigned int i;
@@ -1347,7 +1357,7 @@ channel_open_message()
1347 * channel to host:port from remote side. 1357 * channel to host:port from remote side.
1348 */ 1358 */
1349 1359
1350void 1360void
1351channel_request_local_forwarding(u_short port, const char *host, 1361channel_request_local_forwarding(u_short port, const char *host,
1352 u_short host_port, int gateway_ports) 1362 u_short host_port, int gateway_ports)
1353{ 1363{
@@ -1435,7 +1445,7 @@ channel_request_local_forwarding(u_short port, const char *host,
1435 * the secure channel to host:port from local side. 1445 * the secure channel to host:port from local side.
1436 */ 1446 */
1437 1447
1438void 1448void
1439channel_request_remote_forwarding(u_short listen_port, const char *host_to_connect, 1449channel_request_remote_forwarding(u_short listen_port, const char *host_to_connect,
1440 u_short port_to_connect) 1450 u_short port_to_connect)
1441{ 1451{
@@ -1478,7 +1488,7 @@ channel_request_remote_forwarding(u_short listen_port, const char *host_to_conne
1478 * message if there was an error). This never returns if there was an error. 1488 * message if there was an error). This never returns if there was an error.
1479 */ 1489 */
1480 1490
1481void 1491void
1482channel_input_port_forward_request(int is_root) 1492channel_input_port_forward_request(int is_root)
1483{ 1493{
1484 u_short port, host_port; 1494 u_short port, host_port;
@@ -1562,7 +1572,7 @@ channel_connect_to(const char *host, u_short host_port)
1562 * or CHANNEL_OPEN_FAILURE. 1572 * or CHANNEL_OPEN_FAILURE.
1563 */ 1573 */
1564 1574
1565void 1575void
1566channel_input_port_open(int type, int plen) 1576channel_input_port_open(int type, int plen)
1567{ 1577{
1568 u_short host_port; 1578 u_short host_port;
@@ -1807,7 +1817,7 @@ connect_local_xsocket(unsigned int dnr)
1807 * with either SSH_MSG_OPEN_CONFIRMATION or SSH_MSG_OPEN_FAILURE. 1817 * with either SSH_MSG_OPEN_CONFIRMATION or SSH_MSG_OPEN_FAILURE.
1808 */ 1818 */
1809 1819
1810void 1820void
1811x11_input_open(int type, int plen) 1821x11_input_open(int type, int plen)
1812{ 1822{
1813 int remote_channel, display_number, sock = 0, newch; 1823 int remote_channel, display_number, sock = 0, newch;
@@ -1911,7 +1921,7 @@ x11_input_open(int type, int plen)
1911 } 1921 }
1912 freeaddrinfo(aitop); 1922 freeaddrinfo(aitop);
1913 if (!ai) { 1923 if (!ai) {
1914 error("connect %.100s port %d: %.100s", buf, 6000 + display_number, 1924 error("connect %.100s port %d: %.100s", buf, 6000 + display_number,
1915 strerror(errno)); 1925 strerror(errno));
1916 goto fail; 1926 goto fail;
1917 } 1927 }
@@ -1945,7 +1955,7 @@ fail:
1945 * data, and enables authentication spoofing. 1955 * data, and enables authentication spoofing.
1946 */ 1956 */
1947 1957
1948void 1958void
1949x11_request_forwarding_with_spoofing(const char *proto, const char *data) 1959x11_request_forwarding_with_spoofing(const char *proto, const char *data)
1950{ 1960{
1951 unsigned int data_len = (unsigned int) strlen(data) / 2; 1961 unsigned int data_len = (unsigned int) strlen(data) / 2;
@@ -2003,7 +2013,7 @@ x11_request_forwarding_with_spoofing(const char *proto, const char *data)
2003 2013
2004/* Sends a message to the server to request authentication fd forwarding. */ 2014/* Sends a message to the server to request authentication fd forwarding. */
2005 2015
2006void 2016void
2007auth_request_forwarding() 2017auth_request_forwarding()
2008{ 2018{
2009 packet_start(SSH_CMSG_AGENT_REQUEST_FORWARDING); 2019 packet_start(SSH_CMSG_AGENT_REQUEST_FORWARDING);
@@ -2025,7 +2035,7 @@ auth_get_socket_name()
2025 2035
2026/* removes the agent forwarding socket */ 2036/* removes the agent forwarding socket */
2027 2037
2028void 2038void
2029cleanup_socket(void) 2039cleanup_socket(void)
2030{ 2040{
2031 remove(channel_forwarded_auth_socket_name); 2041 remove(channel_forwarded_auth_socket_name);
@@ -2037,7 +2047,7 @@ cleanup_socket(void)
2037 * This starts forwarding authentication requests. 2047 * This starts forwarding authentication requests.
2038 */ 2048 */
2039 2049
2040void 2050void
2041auth_input_request_forwarding(struct passwd * pw) 2051auth_input_request_forwarding(struct passwd * pw)
2042{ 2052{
2043 int sock, newch; 2053 int sock, newch;
@@ -2095,7 +2105,7 @@ auth_input_request_forwarding(struct passwd * pw)
2095 2105
2096/* This is called to process an SSH_SMSG_AGENT_OPEN message. */ 2106/* This is called to process an SSH_SMSG_AGENT_OPEN message. */
2097 2107
2098void 2108void
2099auth_input_open_request(int type, int plen) 2109auth_input_open_request(int type, int plen)
2100{ 2110{
2101 int remch, sock, newch; 2111 int remch, sock, newch;
diff --git a/channels.h b/channels.h
index 33af09d9d..cab796440 100644
--- a/channels.h
+++ b/channels.h
@@ -1,4 +1,4 @@
1/* RCSID("$Id: channels.h,v 1.6 2000/04/04 04:39:01 damien Exp $"); */ 1/* RCSID("$Id: channels.h,v 1.7 2000/04/16 01:18:41 damien Exp $"); */
2 2
3#ifndef CHANNELS_H 3#ifndef CHANNELS_H
4#define CHANNELS_H 4#define CHANNELS_H
@@ -149,7 +149,7 @@ char *channel_open_message(void);
149 * channel to host:port from remote side. This never returns if there was an 149 * channel to host:port from remote side. This never returns if there was an
150 * error. 150 * error.
151 */ 151 */
152void 152void
153channel_request_local_forwarding(u_short port, const char *host, 153channel_request_local_forwarding(u_short port, const char *host,
154 u_short remote_port, int gateway_ports); 154 u_short remote_port, int gateway_ports);
155 155
@@ -159,7 +159,7 @@ channel_request_local_forwarding(u_short port, const char *host,
159 * there was an error. This registers that open requests for that port are 159 * there was an error. This registers that open requests for that port are
160 * permitted. 160 * permitted.
161 */ 161 */
162void 162void
163channel_request_remote_forwarding(u_short port, const char *host, 163channel_request_remote_forwarding(u_short port, const char *host,
164 u_short remote_port); 164 u_short remote_port);
165 165
diff --git a/cipher.c b/cipher.c
index 1bd8f7c86..edc50dcf4 100644
--- a/cipher.c
+++ b/cipher.c
@@ -1,18 +1,18 @@
1/* 1/*
2 * 2 *
3 * cipher.c 3 * cipher.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Wed Apr 19 17:41:39 1995 ylo 10 * Created: Wed Apr 19 17:41:39 1995 ylo
11 * 11 *
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$Id: cipher.c,v 1.18 2000/04/13 02:26:36 damien Exp $"); 15RCSID("$Id: cipher.c,v 1.19 2000/04/16 01:18:41 damien Exp $");
16 16
17#include "ssh.h" 17#include "ssh.h"
18#include "cipher.h" 18#include "cipher.h"
@@ -138,7 +138,7 @@ static char *cipher_names[] =
138 * supported cipher. 138 * supported cipher.
139 */ 139 */
140 140
141unsigned int 141unsigned int
142cipher_mask1() 142cipher_mask1()
143{ 143{
144 unsigned int mask = 0; 144 unsigned int mask = 0;
@@ -146,7 +146,7 @@ cipher_mask1()
146 mask |= 1 << SSH_CIPHER_BLOWFISH; 146 mask |= 1 << SSH_CIPHER_BLOWFISH;
147 return mask; 147 return mask;
148} 148}
149unsigned int 149unsigned int
150cipher_mask2() 150cipher_mask2()
151{ 151{
152 unsigned int mask = 0; 152 unsigned int mask = 0;
@@ -156,7 +156,7 @@ cipher_mask2()
156 mask |= 1 << SSH_CIPHER_CAST128_CBC; 156 mask |= 1 << SSH_CIPHER_CAST128_CBC;
157 return mask; 157 return mask;
158} 158}
159unsigned int 159unsigned int
160cipher_mask() 160cipher_mask()
161{ 161{
162 return cipher_mask1() | cipher_mask2(); 162 return cipher_mask1() | cipher_mask2();
@@ -218,7 +218,7 @@ cipher_number(const char *name)
218 * passphrase and using the resulting 16 bytes as the key. 218 * passphrase and using the resulting 16 bytes as the key.
219 */ 219 */
220 220
221void 221void
222cipher_set_key_string(CipherContext *context, int cipher, const char *passphrase) 222cipher_set_key_string(CipherContext *context, int cipher, const char *passphrase)
223{ 223{
224 MD5_CTX md; 224 MD5_CTX md;
@@ -236,7 +236,7 @@ cipher_set_key_string(CipherContext *context, int cipher, const char *passphrase
236 236
237/* Selects the cipher to use and sets the key. */ 237/* Selects the cipher to use and sets the key. */
238 238
239void 239void
240cipher_set_key(CipherContext *context, int cipher, const unsigned char *key, 240cipher_set_key(CipherContext *context, int cipher, const unsigned char *key,
241 int keylen) 241 int keylen)
242{ 242{
@@ -297,9 +297,9 @@ cipher_set_key(CipherContext *context, int cipher, const unsigned char *key,
297 memset(padded, 0, sizeof(padded)); 297 memset(padded, 0, sizeof(padded));
298} 298}
299 299
300void 300void
301cipher_set_key_iv(CipherContext * context, int cipher, 301cipher_set_key_iv(CipherContext * context, int cipher,
302 const unsigned char *key, int keylen, 302 const unsigned char *key, int keylen,
303 const unsigned char *iv, int ivlen) 303 const unsigned char *iv, int ivlen)
304{ 304{
305 /* Set cipher type. */ 305 /* Set cipher type. */
@@ -357,7 +357,7 @@ cipher_set_key_iv(CipherContext * context, int cipher,
357 357
358/* Encrypts data using the cipher. */ 358/* Encrypts data using the cipher. */
359 359
360void 360void
361cipher_encrypt(CipherContext *context, unsigned char *dest, 361cipher_encrypt(CipherContext *context, unsigned char *dest,
362 const unsigned char *src, unsigned int len) 362 const unsigned char *src, unsigned int len)
363{ 363{
@@ -379,14 +379,14 @@ cipher_encrypt(CipherContext *context, unsigned char *dest,
379 case SSH_CIPHER_BLOWFISH: 379 case SSH_CIPHER_BLOWFISH:
380 swap_bytes(src, dest, len); 380 swap_bytes(src, dest, len);
381 BF_cbc_encrypt(dest, dest, len, 381 BF_cbc_encrypt(dest, dest, len,
382 &context->u.bf.key, context->u.bf.iv, 382 &context->u.bf.key, context->u.bf.iv,
383 BF_ENCRYPT); 383 BF_ENCRYPT);
384 swap_bytes(dest, dest, len); 384 swap_bytes(dest, dest, len);
385 break; 385 break;
386 386
387 case SSH_CIPHER_BLOWFISH_CBC: 387 case SSH_CIPHER_BLOWFISH_CBC:
388 BF_cbc_encrypt((void *)src, dest, len, 388 BF_cbc_encrypt((void *)src, dest, len,
389 &context->u.bf.key, context->u.bf.iv, 389 &context->u.bf.key, context->u.bf.iv,
390 BF_ENCRYPT); 390 BF_ENCRYPT);
391 break; 391 break;
392 392
@@ -412,7 +412,7 @@ cipher_encrypt(CipherContext *context, unsigned char *dest,
412 412
413/* Decrypts data using the cipher. */ 413/* Decrypts data using the cipher. */
414 414
415void 415void
416cipher_decrypt(CipherContext *context, unsigned char *dest, 416cipher_decrypt(CipherContext *context, unsigned char *dest,
417 const unsigned char *src, unsigned int len) 417 const unsigned char *src, unsigned int len)
418{ 418{
diff --git a/cipher.h b/cipher.h
index 1112bffd9..383e3444f 100644
--- a/cipher.h
+++ b/cipher.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * 2 *
3 * cipher.h 3 * cipher.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Wed Apr 19 16:50:42 1995 ylo 10 * Created: Wed Apr 19 16:50:42 1995 ylo
11 * 11 *
12 */ 12 */
13 13
14/* RCSID("$Id: cipher.h,v 1.10 2000/04/13 02:26:36 damien Exp $"); */ 14/* RCSID("$Id: cipher.h,v 1.11 2000/04/16 01:18:41 damien Exp $"); */
15 15
16#ifndef CIPHER_H 16#ifndef CIPHER_H
17#define CIPHER_H 17#define CIPHER_H
@@ -95,29 +95,29 @@ int ciphers_valid(const char *names);
95 * Selects the cipher to use and sets the key. If for_encryption is true, 95 * Selects the cipher to use and sets the key. If for_encryption is true,
96 * the key is setup for encryption; otherwise it is setup for decryption. 96 * the key is setup for encryption; otherwise it is setup for decryption.
97 */ 97 */
98void 98void
99cipher_set_key(CipherContext * context, int cipher, 99cipher_set_key(CipherContext * context, int cipher,
100 const unsigned char *key, int keylen); 100 const unsigned char *key, int keylen);
101void 101void
102cipher_set_key_iv(CipherContext * context, int cipher, 102cipher_set_key_iv(CipherContext * context, int cipher,
103 const unsigned char *key, int keylen, 103 const unsigned char *key, int keylen,
104 const unsigned char *iv, int ivlen); 104 const unsigned char *iv, int ivlen);
105 105
106/* 106/*
107 * Sets key for the cipher by computing the MD5 checksum of the passphrase, 107 * Sets key for the cipher by computing the MD5 checksum of the passphrase,
108 * and using the resulting 16 bytes as the key. 108 * and using the resulting 16 bytes as the key.
109 */ 109 */
110void 110void
111cipher_set_key_string(CipherContext * context, int cipher, 111cipher_set_key_string(CipherContext * context, int cipher,
112 const char *passphrase); 112 const char *passphrase);
113 113
114/* Encrypts data using the cipher. */ 114/* Encrypts data using the cipher. */
115void 115void
116cipher_encrypt(CipherContext * context, unsigned char *dest, 116cipher_encrypt(CipherContext * context, unsigned char *dest,
117 const unsigned char *src, unsigned int len); 117 const unsigned char *src, unsigned int len);
118 118
119/* Decrypts data using the cipher. */ 119/* Decrypts data using the cipher. */
120void 120void
121cipher_decrypt(CipherContext * context, unsigned char *dest, 121cipher_decrypt(CipherContext * context, unsigned char *dest,
122 const unsigned char *src, unsigned int len); 122 const unsigned char *src, unsigned int len);
123 123
diff --git a/clientloop.c b/clientloop.c
index 91a200663..cc25ca550 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,22 +1,22 @@
1/* 1/*
2 * 2 *
3 * clientloop.c 3 * clientloop.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * 10 *
11 * Created: Sat Sep 23 12:23:57 1995 ylo 11 * Created: Sat Sep 23 12:23:57 1995 ylo
12 * 12 *
13 * The main loop for the interactive session (client side). 13 * The main loop for the interactive session (client side).
14 * 14 *
15 * SSH2 support added by Markus Friedl. 15 * SSH2 support added by Markus Friedl.
16 */ 16 */
17 17
18#include "includes.h" 18#include "includes.h"
19RCSID("$Id: clientloop.c,v 1.10 2000/04/12 10:17:39 damien Exp $"); 19RCSID("$Id: clientloop.c,v 1.11 2000/04/16 01:18:41 damien Exp $");
20 20
21#include "xmalloc.h" 21#include "xmalloc.h"
22#include "ssh.h" 22#include "ssh.h"
@@ -83,7 +83,7 @@ int session_ident = -1;
83 83
84/* Returns the user\'s terminal to normal mode if it had been put in raw mode. */ 84/* Returns the user\'s terminal to normal mode if it had been put in raw mode. */
85 85
86void 86void
87leave_raw_mode() 87leave_raw_mode()
88{ 88{
89 if (!in_raw_mode) 89 if (!in_raw_mode)
@@ -97,7 +97,7 @@ leave_raw_mode()
97 97
98/* Puts the user\'s terminal in raw mode. */ 98/* Puts the user\'s terminal in raw mode. */
99 99
100void 100void
101enter_raw_mode() 101enter_raw_mode()
102{ 102{
103 struct termios tio; 103 struct termios tio;
@@ -123,7 +123,7 @@ enter_raw_mode()
123 123
124/* Restores stdin to blocking mode. */ 124/* Restores stdin to blocking mode. */
125 125
126void 126void
127leave_non_blocking() 127leave_non_blocking()
128{ 128{
129 if (in_non_blocking_mode) { 129 if (in_non_blocking_mode) {
@@ -135,7 +135,7 @@ leave_non_blocking()
135 135
136/* Puts stdin terminal in non-blocking mode. */ 136/* Puts stdin terminal in non-blocking mode. */
137 137
138void 138void
139enter_non_blocking() 139enter_non_blocking()
140{ 140{
141 in_non_blocking_mode = 1; 141 in_non_blocking_mode = 1;
@@ -148,7 +148,7 @@ enter_non_blocking()
148 * flag indicating that the window has changed. 148 * flag indicating that the window has changed.
149 */ 149 */
150 150
151void 151void
152window_change_handler(int sig) 152window_change_handler(int sig)
153{ 153{
154 received_window_change_signal = 1; 154 received_window_change_signal = 1;
@@ -160,7 +160,7 @@ window_change_handler(int sig)
160 * signals must be trapped to restore terminal modes. 160 * signals must be trapped to restore terminal modes.
161 */ 161 */
162 162
163void 163void
164signal_handler(int sig) 164signal_handler(int sig)
165{ 165{
166 if (in_raw_mode) 166 if (in_raw_mode)
@@ -177,7 +177,7 @@ signal_handler(int sig)
177 * available resolution. 177 * available resolution.
178 */ 178 */
179 179
180double 180double
181get_current_time() 181get_current_time()
182{ 182{
183 struct timeval tv; 183 struct timeval tv;
@@ -191,7 +191,7 @@ get_current_time()
191 * not appear to wake up when redirecting from /dev/null. 191 * not appear to wake up when redirecting from /dev/null.
192 */ 192 */
193 193
194void 194void
195client_check_initial_eof_on_stdin() 195client_check_initial_eof_on_stdin()
196{ 196{
197 int len; 197 int len;
@@ -245,7 +245,7 @@ client_check_initial_eof_on_stdin()
245 * connection. 245 * connection.
246 */ 246 */
247 247
248void 248void
249client_make_packets_from_stdin_data() 249client_make_packets_from_stdin_data()
250{ 250{
251 unsigned int len; 251 unsigned int len;
@@ -276,7 +276,7 @@ client_make_packets_from_stdin_data()
276 * appropriate. 276 * appropriate.
277 */ 277 */
278 278
279void 279void
280client_check_window_change() 280client_check_window_change()
281{ 281{
282 struct winsize ws; 282 struct winsize ws;
@@ -313,7 +313,7 @@ client_check_window_change()
313 * one of the file descriptors). 313 * one of the file descriptors).
314 */ 314 */
315 315
316void 316void
317client_wait_until_can_do_something(fd_set * readset, fd_set * writeset) 317client_wait_until_can_do_something(fd_set * readset, fd_set * writeset)
318{ 318{
319 /*debug("client_wait_until_can_do_something"); */ 319 /*debug("client_wait_until_can_do_something"); */
@@ -380,7 +380,7 @@ client_wait_until_can_do_something(fd_set * readset, fd_set * writeset)
380 } 380 }
381} 381}
382 382
383void 383void
384client_suspend_self() 384client_suspend_self()
385{ 385{
386 struct winsize oldws, newws; 386 struct winsize oldws, newws;
@@ -425,7 +425,7 @@ client_suspend_self()
425 enter_raw_mode(); 425 enter_raw_mode();
426} 426}
427 427
428void 428void
429client_process_net_input(fd_set * readset) 429client_process_net_input(fd_set * readset)
430{ 430{
431 int len; 431 int len;
@@ -468,7 +468,7 @@ client_process_net_input(fd_set * readset)
468 } 468 }
469} 469}
470 470
471void 471void
472client_process_input(fd_set * readset) 472client_process_input(fd_set * readset)
473{ 473{
474 int len, pid; 474 int len, pid;
@@ -657,7 +657,7 @@ Supported escape sequences:\r\n\
657 } 657 }
658} 658}
659 659
660void 660void
661client_process_output(fd_set * writeset) 661client_process_output(fd_set * writeset)
662{ 662{
663 int len; 663 int len;
@@ -717,7 +717,7 @@ client_process_output(fd_set * writeset)
717 * preparatory phase. 717 * preparatory phase.
718 */ 718 */
719 719
720void 720void
721client_process_buffered_input_packets() 721client_process_buffered_input_packets()
722{ 722{
723 dispatch_run(DISPATCH_NONBLOCK, &quit_pending); 723 dispatch_run(DISPATCH_NONBLOCK, &quit_pending);
@@ -730,7 +730,7 @@ client_process_buffered_input_packets()
730 * character for terminating or suspending the session. 730 * character for terminating or suspending the session.
731 */ 731 */
732 732
733int 733int
734client_loop(int have_pty, int escape_char_arg) 734client_loop(int have_pty, int escape_char_arg)
735{ 735{
736 extern Options options; 736 extern Options options;
@@ -953,7 +953,7 @@ client_input_exit_status(int type, int plen)
953 quit_pending = 1; 953 quit_pending = 1;
954} 954}
955 955
956void 956void
957client_init_dispatch_20() 957client_init_dispatch_20()
958{ 958{
959 dispatch_init(&dispatch_protocol_error); 959 dispatch_init(&dispatch_protocol_error);
@@ -966,7 +966,7 @@ client_init_dispatch_20()
966 dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &channel_input_channel_request); 966 dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &channel_input_channel_request);
967 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust); 967 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust);
968} 968}
969void 969void
970client_init_dispatch_13() 970client_init_dispatch_13()
971{ 971{
972 dispatch_init(NULL); 972 dispatch_init(NULL);
@@ -983,14 +983,14 @@ client_init_dispatch_13()
983 dispatch_set(SSH_SMSG_STDOUT_DATA, &client_input_stdout_data); 983 dispatch_set(SSH_SMSG_STDOUT_DATA, &client_input_stdout_data);
984 dispatch_set(SSH_SMSG_X11_OPEN, &x11_input_open); 984 dispatch_set(SSH_SMSG_X11_OPEN, &x11_input_open);
985} 985}
986void 986void
987client_init_dispatch_15() 987client_init_dispatch_15()
988{ 988{
989 client_init_dispatch_13(); 989 client_init_dispatch_13();
990 dispatch_set(SSH_MSG_CHANNEL_CLOSE, &channel_input_ieof); 990 dispatch_set(SSH_MSG_CHANNEL_CLOSE, &channel_input_ieof);
991 dispatch_set(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, & channel_input_oclose); 991 dispatch_set(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, & channel_input_oclose);
992} 992}
993void 993void
994client_init_dispatch() 994client_init_dispatch()
995{ 995{
996 if (compat20) 996 if (compat20)
@@ -1027,6 +1027,7 @@ client_input_channel_req(int id, void *arg)
1027 } else if (strcmp(rtype, "exit-status") == 0) { 1027 } else if (strcmp(rtype, "exit-status") == 0) {
1028 success = 1; 1028 success = 1;
1029 exit_status = packet_get_int(); 1029 exit_status = packet_get_int();
1030 packet_done();
1030 } 1031 }
1031 if (reply) { 1032 if (reply) {
1032 packet_start(success ? 1033 packet_start(success ?
diff --git a/compat.c b/compat.c
index d56e3e81d..4673e3fbc 100644
--- a/compat.c
+++ b/compat.c
@@ -28,7 +28,7 @@
28 */ 28 */
29 29
30#include "includes.h" 30#include "includes.h"
31RCSID("$Id: compat.c,v 1.7 2000/04/12 10:17:39 damien Exp $"); 31RCSID("$Id: compat.c,v 1.8 2000/04/16 01:18:42 damien Exp $");
32 32
33#include "ssh.h" 33#include "ssh.h"
34#include "packet.h" 34#include "packet.h"
@@ -39,14 +39,14 @@ int compat13 = 0;
39int compat20 = 0; 39int compat20 = 0;
40int datafellows = 0; 40int datafellows = 0;
41 41
42void 42void
43enable_compat20(void) 43enable_compat20(void)
44{ 44{
45 verbose("Enabling compatibility mode for protocol 2.0"); 45 verbose("Enabling compatibility mode for protocol 2.0");
46 compat20 = 1; 46 compat20 = 1;
47 packet_set_ssh2_format(); 47 packet_set_ssh2_format();
48} 48}
49void 49void
50enable_compat13(void) 50enable_compat13(void)
51{ 51{
52 verbose("Enabling compatibility mode for protocol 1.3"); 52 verbose("Enabling compatibility mode for protocol 1.3");
diff --git a/compress.c b/compress.c
index ee5cdccb5..610aaf7e6 100644
--- a/compress.c
+++ b/compress.c
@@ -1,20 +1,20 @@
1/* 1/*
2 * 2 *
3 * compress.c 3 * compress.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Wed Oct 25 22:12:46 1995 ylo 10 * Created: Wed Oct 25 22:12:46 1995 ylo
11 * 11 *
12 * Interface to packet compression for ssh. 12 * Interface to packet compression for ssh.
13 * 13 *
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$Id: compress.c,v 1.5 2000/04/01 01:09:24 damien Exp $"); 17RCSID("$Id: compress.c,v 1.6 2000/04/16 01:18:42 damien Exp $");
18 18
19#include "ssh.h" 19#include "ssh.h"
20#include "buffer.h" 20#include "buffer.h"
@@ -28,7 +28,7 @@ static z_stream outgoing_stream;
28 * (as in gzip). 28 * (as in gzip).
29 */ 29 */
30 30
31void 31void
32buffer_compress_init(int level) 32buffer_compress_init(int level)
33{ 33{
34 debug("Enabling compression at level %d.", level); 34 debug("Enabling compression at level %d.", level);
@@ -40,7 +40,7 @@ buffer_compress_init(int level)
40 40
41/* Frees any data structures allocated for compression. */ 41/* Frees any data structures allocated for compression. */
42 42
43void 43void
44buffer_compress_uninit() 44buffer_compress_uninit()
45{ 45{
46 debug("compress outgoing: raw data %lu, compressed %lu, factor %.2f", 46 debug("compress outgoing: raw data %lu, compressed %lu, factor %.2f",
@@ -64,7 +64,7 @@ buffer_compress_uninit()
64 * receiver. This appends the compressed data to the output buffer. 64 * receiver. This appends the compressed data to the output buffer.
65 */ 65 */
66 66
67void 67void
68buffer_compress(Buffer * input_buffer, Buffer * output_buffer) 68buffer_compress(Buffer * input_buffer, Buffer * output_buffer)
69{ 69{
70 char buf[4096]; 70 char buf[4096];
@@ -108,7 +108,7 @@ buffer_compress(Buffer * input_buffer, Buffer * output_buffer)
108 * with that. This appends the uncompressed data to the output buffer. 108 * with that. This appends the uncompressed data to the output buffer.
109 */ 109 */
110 110
111void 111void
112buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer) 112buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer)
113{ 113{
114 char buf[4096]; 114 char buf[4096];
diff --git a/compress.h b/compress.h
index 41279a0bd..f13183324 100644
--- a/compress.h
+++ b/compress.h
@@ -1,19 +1,19 @@
1/* 1/*
2 * 2 *
3 * compress.h 3 * compress.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Wed Oct 25 22:12:46 1995 ylo 10 * Created: Wed Oct 25 22:12:46 1995 ylo
11 * 11 *
12 * Interface to packet compression for ssh. 12 * Interface to packet compression for ssh.
13 * 13 *
14 */ 14 */
15 15
16/* RCSID("$Id: compress.h,v 1.3 1999/11/25 00:54:59 damien Exp $"); */ 16/* RCSID("$Id: compress.h,v 1.4 2000/04/16 01:18:42 damien Exp $"); */
17 17
18#ifndef COMPRESS_H 18#ifndef COMPRESS_H
19#define COMPRESS_H 19#define COMPRESS_H
diff --git a/crc32.h b/crc32.h
index d20a8ab15..15ac29999 100644
--- a/crc32.h
+++ b/crc32.h
@@ -1,19 +1,19 @@
1/* 1/*
2 * 2 *
3 * crc32.h 3 * crc32.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1992 Tatu Ylonen, Espoo, Finland 7 * Copyright (c) 1992 Tatu Ylonen, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Tue Feb 11 14:37:27 1992 ylo 10 * Created: Tue Feb 11 14:37:27 1992 ylo
11 * 11 *
12 * Functions for computing 32-bit CRC. 12 * Functions for computing 32-bit CRC.
13 * 13 *
14 */ 14 */
15 15
16/* RCSID("$Id: crc32.h,v 1.3 1999/11/25 00:54:59 damien Exp $"); */ 16/* RCSID("$Id: crc32.h,v 1.4 2000/04/16 01:18:42 damien Exp $"); */
17 17
18#ifndef CRC32_H 18#ifndef CRC32_H
19#define CRC32_H 19#define CRC32_H
diff --git a/dispatch.c b/dispatch.c
new file mode 100644
index 000000000..50f11f3cc
--- /dev/null
+++ b/dispatch.c
@@ -0,0 +1,78 @@
1/*
2 * Copyright (c) 2000 Markus Friedl. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. All advertising materials mentioning features or use of this software
13 * must display the following acknowledgement:
14 * This product includes software developed by Markus Friedl.
15 * 4. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29#include "includes.h"
30RCSID("$Id: dispatch.c,v 1.3 2000/04/16 01:18:42 damien Exp $");
31#include "ssh.h"
32#include "dispatch.h"
33#include "packet.h"
34
35#define DISPATCH_MIN 0
36#define DISPATCH_MAX 255
37
38dispatch_fn *dispatch[DISPATCH_MAX];
39
40void
41dispatch_protocol_error(int type, int plen)
42{
43 error("Hm, dispatch protocol error: type %d plen %d", type, plen);
44}
45void
46dispatch_init(dispatch_fn *dflt)
47{
48 int i;
49 for (i = 0; i < DISPATCH_MAX; i++)
50 dispatch[i] = dflt;
51}
52void
53dispatch_set(int type, dispatch_fn *fn)
54{
55 dispatch[type] = fn;
56}
57void
58dispatch_run(int mode, int *done)
59{
60 for (;;) {
61 int plen;
62 int type;
63
64 if (mode == DISPATCH_BLOCK) {
65 type = packet_read(&plen);
66 } else {
67 type = packet_read_poll(&plen);
68 if (type == SSH_MSG_NONE)
69 return;
70 }
71 if (type > 0 && type < DISPATCH_MAX && dispatch[type] != NULL)
72 (*dispatch[type])(type, plen);
73 else
74 packet_disconnect("protocol error: rcvd type %d", type);
75 if (done != NULL && *done)
76 return;
77 }
78}
diff --git a/dsa.c b/dsa.c
index 935435677..778d43d59 100644
--- a/dsa.c
+++ b/dsa.c
@@ -28,7 +28,7 @@
28 */ 28 */
29 29
30#include "includes.h" 30#include "includes.h"
31RCSID("$Id: dsa.c,v 1.3 2000/04/12 09:39:10 markus Exp $"); 31RCSID("$Id: dsa.c,v 1.4 2000/04/14 10:30:31 markus Exp $");
32 32
33#include "ssh.h" 33#include "ssh.h"
34#include "xmalloc.h" 34#include "xmalloc.h"
@@ -108,7 +108,7 @@ dsa_load_private(char *filename)
108 in = BIO_new(BIO_s_file()); 108 in = BIO_new(BIO_s_file());
109 if (in == NULL) 109 if (in == NULL)
110 fatal("BIO_new failed"); 110 fatal("BIO_new failed");
111 if (BIO_read_filename(in, filename) <= 0) 111 if (BIO_read_filename(in, filename) <= 0)
112 fatal("BIO_read failed %s: %s", filename, strerror(errno)); 112 fatal("BIO_read failed %s: %s", filename, strerror(errno));
113 fprintf(stderr, "read DSA private key\n"); 113 fprintf(stderr, "read DSA private key\n");
114 dsa = PEM_read_bio_DSAPrivateKey(in,NULL,NULL,NULL); 114 dsa = PEM_read_bio_DSAPrivateKey(in,NULL,NULL,NULL);
@@ -182,9 +182,9 @@ dsa_sign(
182 182
183 sig = DSA_do_sign(digest, evp_md->md_size, key->dsa); 183 sig = DSA_do_sign(digest, evp_md->md_size, key->dsa);
184 184
185 rlen = BN_num_bytes(sig->r); 185 rlen = BN_num_bytes(sig->r);
186 slen = BN_num_bytes(sig->s); 186 slen = BN_num_bytes(sig->s);
187 if (rlen > INTBLOB_LEN || slen > INTBLOB_LEN) { 187 if (rlen > INTBLOB_LEN || slen > INTBLOB_LEN) {
188 error("bad sig size %d %d", rlen, slen); 188 error("bad sig size %d %d", rlen, slen);
189 DSA_SIG_free(sig); 189 DSA_SIG_free(sig);
190 return -1; 190 return -1;
diff --git a/getput.h b/getput.h
index 9ab5a22c1..22235f5d9 100644
--- a/getput.h
+++ b/getput.h
@@ -1,19 +1,19 @@
1/* 1/*
2 * 2 *
3 * getput.h 3 * getput.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Wed Jun 28 22:36:30 1995 ylo 10 * Created: Wed Jun 28 22:36:30 1995 ylo
11 * 11 *
12 * Macros for storing and retrieving data in msb first and lsb first order. 12 * Macros for storing and retrieving data in msb first and lsb first order.
13 * 13 *
14 */ 14 */
15 15
16/* RCSID("$Id: getput.h,v 1.2 1999/11/24 13:26:22 damien Exp $"); */ 16/* RCSID("$Id: getput.h,v 1.3 2000/04/16 01:18:42 damien Exp $"); */
17 17
18#ifndef GETPUT_H 18#ifndef GETPUT_H
19#define GETPUT_H 19#define GETPUT_H
@@ -21,7 +21,7 @@
21/*------------ macros for storing/extracting msb first words -------------*/ 21/*------------ macros for storing/extracting msb first words -------------*/
22 22
23#define GET_32BIT(cp) (((unsigned long)(unsigned char)(cp)[0] << 24) | \ 23#define GET_32BIT(cp) (((unsigned long)(unsigned char)(cp)[0] << 24) | \
24 ((unsigned long)(unsigned char)(cp)[1] << 16) | \ 24 ((unsigned long)(unsigned char)(cp)[1] << 16) | \
25 ((unsigned long)(unsigned char)(cp)[2] << 8) | \ 25 ((unsigned long)(unsigned char)(cp)[2] << 8) | \
26 ((unsigned long)(unsigned char)(cp)[3])) 26 ((unsigned long)(unsigned char)(cp)[3]))
27 27
diff --git a/hostfile.c b/hostfile.c
index c594c29aa..b027075af 100644
--- a/hostfile.c
+++ b/hostfile.c
@@ -1,20 +1,20 @@
1/* 1/*
2 * 2 *
3 * hostfile.c 3 * hostfile.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Thu Jun 29 07:10:56 1995 ylo 10 * Created: Thu Jun 29 07:10:56 1995 ylo
11 * 11 *
12 * Functions for manipulating the known hosts files. 12 * Functions for manipulating the known hosts files.
13 * 13 *
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$OpenBSD: hostfile.c,v 1.15 2000/04/12 09:39:10 markus Exp $"); 17RCSID("$OpenBSD: hostfile.c,v 1.16 2000/04/14 10:30:31 markus Exp $");
18 18
19#ifdef HAVE_OPENSSL 19#ifdef HAVE_OPENSSL
20#include <openssl/bn.h> 20#include <openssl/bn.h>
diff --git a/hostfile.h b/hostfile.h
index 64fe185da..c9bdd7f2e 100644
--- a/hostfile.h
+++ b/hostfile.h
@@ -10,7 +10,7 @@
10typedef enum { 10typedef enum {
11 HOST_OK, HOST_NEW, HOST_CHANGED 11 HOST_OK, HOST_NEW, HOST_CHANGED
12} HostStatus; 12} HostStatus;
13HostStatus 13HostStatus
14check_host_in_hostfile(const char *filename, const char *host, Key *key, Key *found); 14check_host_in_hostfile(const char *filename, const char *host, Key *key, Key *found);
15 15
16/* 16/*
diff --git a/includes.h b/includes.h
index 746e76e58..512266762 100644
--- a/includes.h
+++ b/includes.h
@@ -1,16 +1,16 @@
1/* 1/*
2 * 2 *
3 * includes.h 3 * includes.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Thu Mar 23 16:29:37 1995 ylo 10 * Created: Thu Mar 23 16:29:37 1995 ylo
11 * 11 *
12 * This file includes most of the needed system headers. 12 * This file includes most of the needed system headers.
13 * 13 *
14 */ 14 */
15 15
16#ifndef INCLUDES_H 16#ifndef INCLUDES_H
diff --git a/kex.c b/kex.c
index c747b6c4a..4b5266937 100644
--- a/kex.c
+++ b/kex.c
@@ -28,7 +28,7 @@
28 */ 28 */
29 29
30#include "includes.h" 30#include "includes.h"
31RCSID("$Id: kex.c,v 1.4 2000/04/13 02:26:36 damien Exp $"); 31RCSID("$Id: kex.c,v 1.5 2000/04/16 01:18:43 damien Exp $");
32 32
33#include "ssh.h" 33#include "ssh.h"
34#include "ssh2.h" 34#include "ssh2.h"
@@ -149,12 +149,12 @@ void
149dump_digest(unsigned char *digest, int len) 149dump_digest(unsigned char *digest, int len)
150{ 150{
151 int i; 151 int i;
152 for (i = 0; i< len; i++){ 152 for (i = 0; i< len; i++){
153 fprintf(stderr, "%02x", digest[i]); 153 fprintf(stderr, "%02x", digest[i]);
154 if(i%2!=0) 154 if(i%2!=0)
155 fprintf(stderr, " "); 155 fprintf(stderr, " ");
156 } 156 }
157 fprintf(stderr, "\n"); 157 fprintf(stderr, "\n");
158} 158}
159 159
160unsigned char * 160unsigned char *
@@ -201,7 +201,7 @@ kex_hash(
201 buffer_free(&b); 201 buffer_free(&b);
202 202
203#ifdef DEBUG_KEX 203#ifdef DEBUG_KEX
204 dump_digest(digest, evp_md->md_size); 204 dump_digest(digest, evp_md->md_size);
205#endif 205#endif
206 return digest; 206 return digest;
207} 207}
@@ -345,7 +345,7 @@ choose_kex(Kex *k, char *client, char *server)
345 k->name = get_match(client, server); 345 k->name = get_match(client, server);
346 if (k->name == NULL) 346 if (k->name == NULL)
347 fatal("no kex alg"); 347 fatal("no kex alg");
348 if (strcmp(k->name, KEX_DH1) != 0) 348 if (strcmp(k->name, KEX_DH1) != 0)
349 fatal("bad kex alg %s", k->name); 349 fatal("bad kex alg %s", k->name);
350} 350}
351void 351void
diff --git a/log-client.c b/log-client.c
index 11ac45d7a..e86a2e330 100644
--- a/log-client.c
+++ b/log-client.c
@@ -1,21 +1,21 @@
1/* 1/*
2 * 2 *
3 * log-client.c 3 * log-client.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Mon Mar 20 21:13:40 1995 ylo 10 * Created: Mon Mar 20 21:13:40 1995 ylo
11 * 11 *
12 * Client-side versions of debug(), log(), etc. These print to stderr. 12 * Client-side versions of debug(), log(), etc. These print to stderr.
13 * This is a stripped down version of log-server.c. 13 * This is a stripped down version of log-server.c.
14 * 14 *
15 */ 15 */
16 16
17#include "includes.h" 17#include "includes.h"
18RCSID("$Id: log-client.c,v 1.5 2000/03/09 10:27:50 damien Exp $"); 18RCSID("$Id: log-client.c,v 1.6 2000/04/16 01:18:43 damien Exp $");
19 19
20#include "xmalloc.h" 20#include "xmalloc.h"
21#include "ssh.h" 21#include "ssh.h"
diff --git a/log-server.c b/log-server.c
index 476e49f80..9070b6530 100644
--- a/log-server.c
+++ b/log-server.c
@@ -1,21 +1,21 @@
1/* 1/*
2 * 2 *
3 * log-server.c 3 * log-server.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Mon Mar 20 21:19:30 1995 ylo 10 * Created: Mon Mar 20 21:19:30 1995 ylo
11 * 11 *
12 * Server-side versions of debug(), log(), etc. These normally send the output 12 * Server-side versions of debug(), log(), etc. These normally send the output
13 * to the system log. 13 * to the system log.
14 * 14 *
15 */ 15 */
16 16
17#include "includes.h" 17#include "includes.h"
18RCSID("$Id: log-server.c,v 1.8 2000/04/01 01:09:24 damien Exp $"); 18RCSID("$Id: log-server.c,v 1.9 2000/04/16 01:18:43 damien Exp $");
19 19
20#include <syslog.h> 20#include <syslog.h>
21#include "packet.h" 21#include "packet.h"
@@ -38,7 +38,7 @@ static int log_facility = LOG_AUTH;
38 * level logging level 38 * level logging level
39 */ 39 */
40 40
41void 41void
42log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr) 42log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr)
43{ 43{
44 switch (level) { 44 switch (level) {
diff --git a/login.c b/login.c
index da11b245f..b4a8bafca 100644
--- a/login.c
+++ b/login.c
@@ -1,24 +1,24 @@
1/* 1/*
2 * 2 *
3 * login.c 3 * login.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Fri Mar 24 14:51:08 1995 ylo 10 * Created: Fri Mar 24 14:51:08 1995 ylo
11 * 11 *
12 * This file performs some of the things login(1) normally does. We cannot 12 * This file performs some of the things login(1) normally does. We cannot
13 * easily use something like login -p -h host -f user, because there are 13 * easily use something like login -p -h host -f user, because there are
14 * several different logins around, and it is hard to determined what kind of 14 * several different logins around, and it is hard to determined what kind of
15 * login the current system has. Also, we want to be able to execute commands 15 * login the current system has. Also, we want to be able to execute commands
16 * on a tty. 16 * on a tty.
17 * 17 *
18 */ 18 */
19 19
20#include "includes.h" 20#include "includes.h"
21RCSID("$Id: login.c,v 1.22 2000/02/02 08:17:41 damien Exp $"); 21RCSID("$Id: login.c,v 1.23 2000/04/16 01:18:43 damien Exp $");
22 22
23#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) 23#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
24# include <utmpx.h> 24# include <utmpx.h>
@@ -49,7 +49,7 @@ RCSID("$Id: login.c,v 1.22 2000/02/02 08:17:41 damien Exp $");
49 * is found). The name of the host used last time is returned in buf. 49 * is found). The name of the host used last time is returned in buf.
50 */ 50 */
51 51
52unsigned long 52unsigned long
53get_last_login_time(uid_t uid, const char *logname, 53get_last_login_time(uid_t uid, const char *logname,
54 char *buf, unsigned int bufsize) 54 char *buf, unsigned int bufsize)
55{ 55{
@@ -135,7 +135,7 @@ get_last_login_time(uid_t uid, const char *logname,
135 * were more standardized. 135 * were more standardized.
136 */ 136 */
137 137
138void 138void
139record_login(int pid, const char *ttyname, const char *user, uid_t uid, 139record_login(int pid, const char *ttyname, const char *user, uid_t uid,
140 const char *host, struct sockaddr * addr) 140 const char *host, struct sockaddr * addr)
141{ 141{
@@ -273,7 +273,7 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid,
273 273
274/* Records that the user has logged out. */ 274/* Records that the user has logged out. */
275 275
276void 276void
277record_logout(int pid, const char *ttyname) 277record_logout(int pid, const char *ttyname)
278{ 278{
279#ifdef HAVE_LIBUTIL_LOGIN 279#ifdef HAVE_LIBUTIL_LOGIN
diff --git a/match.c b/match.c
index b72efca7e..ef9498599 100644
--- a/match.c
+++ b/match.c
@@ -1,20 +1,20 @@
1/* 1/*
2 * 2 *
3 * match.c 3 * match.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Thu Jun 22 01:17:50 1995 ylo 10 * Created: Thu Jun 22 01:17:50 1995 ylo
11 * 11 *
12 * Simple pattern matching, with '*' and '?' as wildcards. 12 * Simple pattern matching, with '*' and '?' as wildcards.
13 * 13 *
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$Id: match.c,v 1.4 2000/03/26 03:04:53 damien Exp $"); 17RCSID("$Id: match.c,v 1.5 2000/04/16 01:18:43 damien Exp $");
18 18
19#include "ssh.h" 19#include "ssh.h"
20 20
@@ -23,7 +23,7 @@ RCSID("$Id: match.c,v 1.4 2000/03/26 03:04:53 damien Exp $");
23 * and * as wildcards), and zero if it does not match. 23 * and * as wildcards), and zero if it does not match.
24 */ 24 */
25 25
26int 26int
27match_pattern(const char *s, const char *pattern) 27match_pattern(const char *s, const char *pattern)
28{ 28{
29 for (;;) { 29 for (;;) {
diff --git a/mpaux.c b/mpaux.c
index 8ce89dcc4..4deefe689 100644
--- a/mpaux.c
+++ b/mpaux.c
@@ -1,21 +1,21 @@
1/* 1/*
2 * 2 *
3 * mpaux.c 3 * mpaux.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Sun Jul 16 04:29:30 1995 ylo 10 * Created: Sun Jul 16 04:29:30 1995 ylo
11 * 11 *
12 * This file contains various auxiliary functions related to multiple 12 * This file contains various auxiliary functions related to multiple
13 * precision integers. 13 * precision integers.
14 * 14 *
15*/ 15*/
16 16
17#include "includes.h" 17#include "includes.h"
18RCSID("$Id: mpaux.c,v 1.10 2000/04/13 02:26:36 damien Exp $"); 18RCSID("$Id: mpaux.c,v 1.11 2000/04/16 01:18:43 damien Exp $");
19 19
20#include "getput.h" 20#include "getput.h"
21#include "xmalloc.h" 21#include "xmalloc.h"
diff --git a/mpaux.h b/mpaux.h
index 105bc3148..d3e24cfd6 100644
--- a/mpaux.h
+++ b/mpaux.h
@@ -1,19 +1,19 @@
1/* 1/*
2 * 2 *
3 * mpaux.h 3 * mpaux.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Sun Jul 16 04:29:30 1995 ylo 10 * Created: Sun Jul 16 04:29:30 1995 ylo
11 * 11 *
12 * This file contains various auxiliary functions related to multiple 12 * This file contains various auxiliary functions related to multiple
13 * precision integers. 13 * precision integers.
14 */ 14 */
15 15
16/* RCSID("$Id: mpaux.h,v 1.4 1999/11/25 00:54:59 damien Exp $"); */ 16/* RCSID("$Id: mpaux.h,v 1.5 2000/04/16 01:18:43 damien Exp $"); */
17 17
18#ifndef MPAUX_H 18#ifndef MPAUX_H
19#define MPAUX_H 19#define MPAUX_H
@@ -23,7 +23,7 @@
23 * session id is computed by concatenating the linearized, msb first 23 * session id is computed by concatenating the linearized, msb first
24 * representations of host_key_n, session_key_n, and the cookie. 24 * representations of host_key_n, session_key_n, and the cookie.
25 */ 25 */
26void 26void
27compute_session_id(unsigned char session_id[16], 27compute_session_id(unsigned char session_id[16],
28 unsigned char cookie[8], 28 unsigned char cookie[8],
29 BIGNUM * host_key_n, 29 BIGNUM * host_key_n,
diff --git a/nchan.c b/nchan.c
index 3795d8ad4..f2dace0e4 100644
--- a/nchan.c
+++ b/nchan.c
@@ -28,7 +28,7 @@
28 */ 28 */
29 29
30#include "includes.h" 30#include "includes.h"
31RCSID("$Id: nchan.c,v 1.7 2000/04/04 04:39:02 damien Exp $"); 31RCSID("$Id: nchan.c,v 1.8 2000/04/16 01:18:43 damien Exp $");
32 32
33#include "ssh.h" 33#include "ssh.h"
34 34
@@ -389,11 +389,11 @@ chan_delete_if_full_closed2(Channel *c)
389 if (!(c->flags & CHAN_CLOSE_SENT)) { 389 if (!(c->flags & CHAN_CLOSE_SENT)) {
390 chan_send_close2(c); 390 chan_send_close2(c);
391 } 391 }
392 if ((c->flags & CHAN_CLOSE_SENT) && 392 if ((c->flags & CHAN_CLOSE_SENT) &&
393 (c->flags & CHAN_CLOSE_RCVD)) { 393 (c->flags & CHAN_CLOSE_RCVD)) {
394 debug("channel %d: full closed2", c->self); 394 debug("channel %d: full closed2", c->self);
395 channel_free(c->self); 395 channel_free(c->self);
396 } 396 }
397 } 397 }
398} 398}
399 399
diff --git a/packet.c b/packet.c
index b0dfe4aa7..cb8fa15b4 100644
--- a/packet.c
+++ b/packet.c
@@ -1,14 +1,14 @@
1/* 1/*
2 * 2 *
3 * packet.c 3 * packet.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Sat Mar 18 02:40:40 1995 ylo 10 * Created: Sat Mar 18 02:40:40 1995 ylo
11 * 11 *
12 * This file contains code implementing the packet protocol and communication 12 * This file contains code implementing the packet protocol and communication
13 * with the other side. This same code is used both on client and server side. 13 * with the other side. This same code is used both on client and server side.
14 * 14 *
@@ -17,7 +17,7 @@
17 */ 17 */
18 18
19#include "includes.h" 19#include "includes.h"
20RCSID("$Id: packet.c,v 1.17 2000/04/13 02:26:37 damien Exp $"); 20RCSID("$Id: packet.c,v 1.18 2000/04/16 01:18:43 damien Exp $");
21 21
22#ifdef HAVE_OPENSSL 22#ifdef HAVE_OPENSSL
23# include <openssl/bn.h> 23# include <openssl/bn.h>
@@ -529,7 +529,7 @@ packet_send2()
529 unsigned int packet_length = 0; 529 unsigned int packet_length = 0;
530 unsigned int i, padlen, len; 530 unsigned int i, padlen, len;
531 u_int32_t rand = 0; 531 u_int32_t rand = 0;
532 static unsigned int seqnr = 0; 532 static unsigned int seqnr = 0;
533 int type; 533 int type;
534 Enc *enc = NULL; 534 Enc *enc = NULL;
535 Mac *mac = NULL; 535 Mac *mac = NULL;
@@ -611,9 +611,9 @@ packet_send2()
611 fprintf(stderr, "encrypted: "); 611 fprintf(stderr, "encrypted: ");
612 buffer_dump(&output); 612 buffer_dump(&output);
613#endif 613#endif
614 /* increment sequence number for outgoing packets */ 614 /* increment sequence number for outgoing packets */
615 if (++seqnr == 0) 615 if (++seqnr == 0)
616 log("outgoing seqnr wraps around"); 616 log("outgoing seqnr wraps around");
617 buffer_clear(&outgoing_packet); 617 buffer_clear(&outgoing_packet);
618 618
619 if (type == SSH2_MSG_NEWKEYS) { 619 if (type == SSH2_MSG_NEWKEYS) {
@@ -877,7 +877,7 @@ packet_read_poll2(int *payload_len_ptr)
877 * compute MAC over seqnr and packet, 877 * compute MAC over seqnr and packet,
878 * increment sequence number for incoming packet 878 * increment sequence number for incoming packet
879 */ 879 */
880 if (mac && mac->enabled) { 880 if (mac && mac->enabled) {
881 macbuf = hmac( mac->md, seqnr, 881 macbuf = hmac( mac->md, seqnr,
882 (unsigned char *) buffer_ptr(&incoming_packet), 882 (unsigned char *) buffer_ptr(&incoming_packet),
883 buffer_len(&incoming_packet), 883 buffer_len(&incoming_packet),
@@ -888,8 +888,8 @@ packet_read_poll2(int *payload_len_ptr)
888 DBG(debug("HMAC #%d ok", seqnr)); 888 DBG(debug("HMAC #%d ok", seqnr));
889 buffer_consume(&input, mac->mac_len); 889 buffer_consume(&input, mac->mac_len);
890 } 890 }
891 if (++seqnr == 0) 891 if (++seqnr == 0)
892 log("incoming seqnr wraps around"); 892 log("incoming seqnr wraps around");
893 893
894 /* get padlen */ 894 /* get padlen */
895 cp = buffer_ptr(&incoming_packet) + 4; 895 cp = buffer_ptr(&incoming_packet) + 4;
@@ -1063,6 +1063,12 @@ packet_get_raw(int *length_ptr)
1063 return buffer_ptr(&incoming_packet); 1063 return buffer_ptr(&incoming_packet);
1064} 1064}
1065 1065
1066int
1067packet_remaining(void)
1068{
1069 return buffer_len(&incoming_packet);
1070}
1071
1066/* 1072/*
1067 * Returns a string from the packet data. The string is allocated using 1073 * Returns a string from the packet data. The string is allocated using
1068 * xmalloc; it is the responsibility of the calling program to free it when 1074 * xmalloc; it is the responsibility of the calling program to free it when
diff --git a/packet.h b/packet.h
index 565a9bd36..93495bbfc 100644
--- a/packet.h
+++ b/packet.h
@@ -1,19 +1,19 @@
1/* 1/*
2 * 2 *
3 * packet.h 3 * packet.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Sat Mar 18 02:02:14 1995 ylo 10 * Created: Sat Mar 18 02:02:14 1995 ylo
11 * 11 *
12 * Interface for the packet protocol functions. 12 * Interface for the packet protocol functions.
13 * 13 *
14 */ 14 */
15 15
16/* RCSID("$Id: packet.h,v 1.13 2000/04/13 02:26:37 damien Exp $"); */ 16/* RCSID("$Id: packet.h,v 1.14 2000/04/16 01:18:44 damien Exp $"); */
17 17
18#ifndef PACKET_H 18#ifndef PACKET_H
19#define PACKET_H 19#define PACKET_H
@@ -52,7 +52,7 @@ void packet_close(void);
52 * key is used for both sending and reception. However, both directions are 52 * key is used for both sending and reception. However, both directions are
53 * encrypted independently of each other. Cipher types are defined in ssh.h. 53 * encrypted independently of each other. Cipher types are defined in ssh.h.
54 */ 54 */
55void 55void
56packet_set_encryption_key(const unsigned char *key, unsigned int keylen, 56packet_set_encryption_key(const unsigned char *key, unsigned int keylen,
57 int cipher_type); 57 int cipher_type);
58 58
@@ -201,6 +201,16 @@ do { \
201 } \ 201 } \
202} while (0) 202} while (0)
203 203
204#define packet_done() \
205do { \
206 int _len = packet_remaining(); \
207 if (_len > 0) { \
208 log("Packet integrity error (%d bytes remaining) at %s:%d", \
209 _len ,__FILE__, __LINE__); \
210 packet_disconnect("Packet integrity error."); \
211 } \
212} while (0)
213
204/* remote host is connected via a socket/ipv4 */ 214/* remote host is connected via a socket/ipv4 */
205int packet_connection_is_on_socket(void); 215int packet_connection_is_on_socket(void);
206int packet_connection_is_ipv4(void); 216int packet_connection_is_ipv4(void);
@@ -208,4 +218,7 @@ int packet_connection_is_ipv4(void);
208/* enable SSH2 packet format */ 218/* enable SSH2 packet format */
209void packet_set_ssh2_format(void); 219void packet_set_ssh2_format(void);
210 220
221/* returns remaining payload bytes */
222int packet_remaining(void);
223
211#endif /* PACKET_H */ 224#endif /* PACKET_H */
diff --git a/pty.c b/pty.c
index c34f1f5dc..c6af6f471 100644
--- a/pty.c
+++ b/pty.c
@@ -1,20 +1,20 @@
1/* 1/*
2 * 2 *
3 * pty.c 3 * pty.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Fri Mar 17 04:37:25 1995 ylo 10 * Created: Fri Mar 17 04:37:25 1995 ylo
11 * 11 *
12 * Allocating a pseudo-terminal, and making it the controlling tty. 12 * Allocating a pseudo-terminal, and making it the controlling tty.
13 * 13 *
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$Id: pty.c,v 1.17 2000/03/17 12:58:59 damien Exp $"); 17RCSID("$Id: pty.c,v 1.18 2000/04/16 01:18:44 damien Exp $");
18 18
19#ifdef HAVE_UTIL_H 19#ifdef HAVE_UTIL_H
20# include <util.h> 20# include <util.h>
@@ -46,7 +46,7 @@ RCSID("$Id: pty.c,v 1.17 2000/03/17 12:58:59 damien Exp $");
46 * returned (the buffer must be able to hold at least 64 characters). 46 * returned (the buffer must be able to hold at least 64 characters).
47 */ 47 */
48 48
49int 49int
50pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) 50pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
51{ 51{
52#if defined(HAVE_OPENPTY) || defined(BSD4_4) 52#if defined(HAVE_OPENPTY) || defined(BSD4_4)
@@ -186,7 +186,7 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
186 186
187/* Releases the tty. Its ownership is returned to root, and permissions to 0666. */ 187/* Releases the tty. Its ownership is returned to root, and permissions to 0666. */
188 188
189void 189void
190pty_release(const char *ttyname) 190pty_release(const char *ttyname)
191{ 191{
192 if (chown(ttyname, (uid_t) 0, (gid_t) 0) < 0) 192 if (chown(ttyname, (uid_t) 0, (gid_t) 0) < 0)
@@ -197,7 +197,7 @@ pty_release(const char *ttyname)
197 197
198/* Makes the tty the processes controlling tty and sets it to sane modes. */ 198/* Makes the tty the processes controlling tty and sets it to sane modes. */
199 199
200void 200void
201pty_make_controlling_tty(int *ttyfd, const char *ttyname) 201pty_make_controlling_tty(int *ttyfd, const char *ttyname)
202{ 202{
203 int fd; 203 int fd;
@@ -250,7 +250,7 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
250 250
251/* Changes the window size associated with the pty. */ 251/* Changes the window size associated with the pty. */
252 252
253void 253void
254pty_change_window_size(int ptyfd, int row, int col, 254pty_change_window_size(int ptyfd, int row, int col,
255 int xpixel, int ypixel) 255 int xpixel, int ypixel)
256{ 256{
diff --git a/pty.h b/pty.h
index af6c279d7..a9bdeaee8 100644
--- a/pty.h
+++ b/pty.h
@@ -1,19 +1,19 @@
1/* 1/*
2 * 2 *
3 * pty.h 3 * pty.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Fri Mar 17 05:03:28 1995 ylo 10 * Created: Fri Mar 17 05:03:28 1995 ylo
11 * 11 *
12 * Functions for allocating a pseudo-terminal and making it the controlling 12 * Functions for allocating a pseudo-terminal and making it the controlling
13 * tty. 13 * tty.
14 */ 14 */
15 15
16/* RCSID("$Id: pty.h,v 1.7 2000/04/01 01:09:25 damien Exp $"); */ 16/* RCSID("$Id: pty.h,v 1.8 2000/04/16 01:18:44 damien Exp $"); */
17 17
18#ifndef PTY_H 18#ifndef PTY_H
19#define PTY_H 19#define PTY_H
@@ -39,7 +39,7 @@ void pty_release(const char *ttyname);
39void pty_make_controlling_tty(int *ttyfd, const char *ttyname); 39void pty_make_controlling_tty(int *ttyfd, const char *ttyname);
40 40
41/* Changes the window size associated with the pty. */ 41/* Changes the window size associated with the pty. */
42void 42void
43pty_change_window_size(int ptyfd, int row, int col, 43pty_change_window_size(int ptyfd, int row, int col,
44 int xpixel, int ypixel); 44 int xpixel, int ypixel);
45 45
diff --git a/radix.c b/radix.c
index ea7f5ba2b..84e390fd1 100644
--- a/radix.c
+++ b/radix.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * radix.c 2 * radix.c
3 * 3 *
4 * base-64 encoding pinched from lynx2-7-2, who pinched it from rpem. 4 * base-64 encoding pinched from lynx2-7-2, who pinched it from rpem.
5 * Originally written by Mark Riordan 12 August 1990 and 17 Feb 1991 5 * Originally written by Mark Riordan 12 August 1990 and 17 Feb 1991
6 * and placed in the public domain. 6 * and placed in the public domain.
7 * 7 *
8 * Dug Song <dugsong@UMICH.EDU> 8 * Dug Song <dugsong@UMICH.EDU>
9 */ 9 */
10 10
@@ -23,7 +23,7 @@ char six2pr[64] = {
23 23
24unsigned char pr2six[256]; 24unsigned char pr2six[256];
25 25
26int 26int
27uuencode(unsigned char *bufin, unsigned int nbytes, char *bufcoded) 27uuencode(unsigned char *bufin, unsigned int nbytes, char *bufcoded)
28{ 28{
29 /* ENC is the basic 1 character encoding function to make a char printing */ 29 /* ENC is the basic 1 character encoding function to make a char printing */
@@ -49,7 +49,7 @@ uuencode(unsigned char *bufin, unsigned int nbytes, char *bufcoded)
49 return (outptr - bufcoded); 49 return (outptr - bufcoded);
50} 50}
51 51
52int 52int
53uudecode(const char *bufcoded, unsigned char *bufplain, int outbufsize) 53uudecode(const char *bufcoded, unsigned char *bufplain, int outbufsize)
54{ 54{
55 /* single character decode */ 55 /* single character decode */
@@ -162,7 +162,7 @@ typedef unsigned short my_u_short;
162} 162}
163 163
164 164
165int 165int
166creds_to_radix(CREDENTIALS *creds, unsigned char *buf) 166creds_to_radix(CREDENTIALS *creds, unsigned char *buf)
167{ 167{
168 char *p, *s; 168 char *p, *s;
@@ -216,7 +216,7 @@ creds_to_radix(CREDENTIALS *creds, unsigned char *buf)
216 return (uuencode((unsigned char *)temp, len, (char *)buf)); 216 return (uuencode((unsigned char *)temp, len, (char *)buf));
217} 217}
218 218
219int 219int
220radix_to_creds(const char *buf, CREDENTIALS *creds) 220radix_to_creds(const char *buf, CREDENTIALS *creds)
221{ 221{
222 222
diff --git a/readconf.c b/readconf.c
index 1ba70c36a..3b75290f3 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,20 +1,20 @@
1/* 1/*
2 * 2 *
3 * readconf.c 3 * readconf.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Sat Apr 22 00:03:10 1995 ylo 10 * Created: Sat Apr 22 00:03:10 1995 ylo
11 * 11 *
12 * Functions for reading the configuration files. 12 * Functions for reading the configuration files.
13 * 13 *
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$Id: readconf.c,v 1.10 2000/04/12 10:17:40 damien Exp $"); 17RCSID("$Id: readconf.c,v 1.11 2000/04/16 01:18:44 damien Exp $");
18 18
19#include "ssh.h" 19#include "ssh.h"
20#include "cipher.h" 20#include "cipher.h"
@@ -167,7 +167,7 @@ static struct {
167 * error. 167 * error.
168 */ 168 */
169 169
170void 170void
171add_local_forward(Options *options, u_short port, const char *host, 171add_local_forward(Options *options, u_short port, const char *host,
172 u_short host_port) 172 u_short host_port)
173{ 173{
@@ -188,7 +188,7 @@ add_local_forward(Options *options, u_short port, const char *host,
188 * an error. 188 * an error.
189 */ 189 */
190 190
191void 191void
192add_remote_forward(Options *options, u_short port, const char *host, 192add_remote_forward(Options *options, u_short port, const char *host,
193 u_short host_port) 193 u_short host_port)
194{ 194{
@@ -207,7 +207,7 @@ add_remote_forward(Options *options, u_short port, const char *host,
207 * returns if the token is not known. 207 * returns if the token is not known.
208 */ 208 */
209 209
210static OpCodes 210static OpCodes
211parse_token(const char *cp, const char *filename, int linenum) 211parse_token(const char *cp, const char *filename, int linenum)
212{ 212{
213 unsigned int i; 213 unsigned int i;
@@ -567,7 +567,7 @@ parse_int:
567 * there is an error. If the file does not exist, this returns immediately. 567 * there is an error. If the file does not exist, this returns immediately.
568 */ 568 */
569 569
570void 570void
571read_config_file(const char *filename, const char *host, Options *options) 571read_config_file(const char *filename, const char *host, Options *options)
572{ 572{
573 FILE *f; 573 FILE *f;
@@ -607,7 +607,7 @@ read_config_file(const char *filename, const char *host, Options *options)
607 * system config file. Last, fill_default_options is called. 607 * system config file. Last, fill_default_options is called.
608 */ 608 */
609 609
610void 610void
611initialize_options(Options * options) 611initialize_options(Options * options)
612{ 612{
613 memset(options, 'X', sizeof(*options)); 613 memset(options, 'X', sizeof(*options));
@@ -658,7 +658,7 @@ initialize_options(Options * options)
658 * options for which no value has been specified with their default values. 658 * options for which no value has been specified with their default values.
659 */ 659 */
660 660
661void 661void
662fill_default_options(Options * options) 662fill_default_options(Options * options)
663{ 663{
664 if (options->forward_agent == -1) 664 if (options->forward_agent == -1)
diff --git a/readconf.h b/readconf.h
index 86f342d37..0582a8f2e 100644
--- a/readconf.h
+++ b/readconf.h
@@ -1,19 +1,19 @@
1/* 1/*
2 * 2 *
3 * readconf.h 3 * readconf.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Sat Apr 22 00:25:29 1995 ylo 10 * Created: Sat Apr 22 00:25:29 1995 ylo
11 * 11 *
12 * Functions for reading the configuration file. 12 * Functions for reading the configuration file.
13 * 13 *
14 */ 14 */
15 15
16/* RCSID("$Id: readconf.h,v 1.7 2000/04/12 10:17:40 damien Exp $"); */ 16/* RCSID("$Id: readconf.h,v 1.8 2000/04/16 01:18:44 damien Exp $"); */
17 17
18#ifndef READCONF_H 18#ifndef READCONF_H
19#define READCONF_H 19#define READCONF_H
@@ -106,7 +106,7 @@ void fill_default_options(Options * options);
106 * only sets those values that have not already been set. Returns 0 for legal 106 * only sets those values that have not already been set. Returns 0 for legal
107 * options 107 * options
108 */ 108 */
109int 109int
110process_config_line(Options * options, const char *host, 110process_config_line(Options * options, const char *host,
111 char *line, const char *filename, int linenum, 111 char *line, const char *filename, int linenum,
112 int *activep); 112 int *activep);
@@ -116,7 +116,7 @@ process_config_line(Options * options, const char *host,
116 * should already be initialized before this call. This never returns if 116 * should already be initialized before this call. This never returns if
117 * there is an error. If the file does not exist, this returns immediately. 117 * there is an error. If the file does not exist, this returns immediately.
118 */ 118 */
119void 119void
120read_config_file(const char *filename, const char *host, 120read_config_file(const char *filename, const char *host,
121 Options * options); 121 Options * options);
122 122
@@ -124,7 +124,7 @@ read_config_file(const char *filename, const char *host,
124 * Adds a local TCP/IP port forward to options. Never returns if there is an 124 * Adds a local TCP/IP port forward to options. Never returns if there is an
125 * error. 125 * error.
126 */ 126 */
127void 127void
128add_local_forward(Options * options, u_short port, const char *host, 128add_local_forward(Options * options, u_short port, const char *host,
129 u_short host_port); 129 u_short host_port);
130 130
@@ -132,7 +132,7 @@ add_local_forward(Options * options, u_short port, const char *host,
132 * Adds a remote TCP/IP port forward to options. Never returns if there is 132 * Adds a remote TCP/IP port forward to options. Never returns if there is
133 * an error. 133 * an error.
134 */ 134 */
135void 135void
136add_remote_forward(Options * options, u_short port, const char *host, 136add_remote_forward(Options * options, u_short port, const char *host,
137 u_short host_port); 137 u_short host_port);
138 138
diff --git a/readpass.c b/readpass.c
index edeb23864..e3402b480 100644
--- a/readpass.c
+++ b/readpass.c
@@ -32,7 +32,7 @@
32 */ 32 */
33 33
34#include "includes.h" 34#include "includes.h"
35RCSID("$Id: readpass.c,v 1.5 2000/01/22 08:47:21 damien Exp $"); 35RCSID("$Id: readpass.c,v 1.6 2000/04/16 01:18:44 damien Exp $");
36 36
37#include "xmalloc.h" 37#include "xmalloc.h"
38#include "ssh.h" 38#include "ssh.h"
@@ -58,7 +58,7 @@ read_passphrase(const char *prompt, int from_stdin)
58 sigset_t oset, nset; 58 sigset_t oset, nset;
59 struct sigaction sa, osa; 59 struct sigaction sa, osa;
60 int input, output, echo = 0; 60 int input, output, echo = 0;
61 61
62 if (from_stdin) { 62 if (from_stdin) {
63 input = STDIN_FILENO; 63 input = STDIN_FILENO;
64 output = STDERR_FILENO; 64 output = STDERR_FILENO;
diff --git a/rsa.c b/rsa.c
index 0385a102c..1e8c434f9 100644
--- a/rsa.c
+++ b/rsa.c
@@ -1,41 +1,41 @@
1/* 1/*
2 * 2 *
3 * rsa.c 3 * rsa.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Fri Mar 3 22:07:06 1995 ylo 10 * Created: Fri Mar 3 22:07:06 1995 ylo
11 * 11 *
12 * Description of the RSA algorithm can be found e.g. from the following sources: 12 * Description of the RSA algorithm can be found e.g. from the following sources:
13 * 13 *
14 * Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1994. 14 * Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1994.
15 * 15 *
16 * Jennifer Seberry and Josed Pieprzyk: Cryptography: An Introduction to 16 * Jennifer Seberry and Josed Pieprzyk: Cryptography: An Introduction to
17 * Computer Security. Prentice-Hall, 1989. 17 * Computer Security. Prentice-Hall, 1989.
18 * 18 *
19 * Man Young Rhee: Cryptography and Secure Data Communications. McGraw-Hill, 19 * Man Young Rhee: Cryptography and Secure Data Communications. McGraw-Hill,
20 * 1994. 20 * 1994.
21 * 21 *
22 * R. Rivest, A. Shamir, and L. M. Adleman: Cryptographic Communications 22 * R. Rivest, A. Shamir, and L. M. Adleman: Cryptographic Communications
23 * System and Method. US Patent 4,405,829, 1983. 23 * System and Method. US Patent 4,405,829, 1983.
24 * 24 *
25 * Hans Riesel: Prime Numbers and Computer Methods for Factorization. 25 * Hans Riesel: Prime Numbers and Computer Methods for Factorization.
26 * Birkhauser, 1994. 26 * Birkhauser, 1994.
27 * 27 *
28 * The RSA Frequently Asked Questions document by RSA Data Security, Inc., 1995. 28 * The RSA Frequently Asked Questions document by RSA Data Security, Inc., 1995.
29 * 29 *
30 * RSA in 3 lines of perl by Adam Back <aba@atlax.ex.ac.uk>, 1995, as included 30 * RSA in 3 lines of perl by Adam Back <aba@atlax.ex.ac.uk>, 1995, as included
31 * below: 31 * below:
32 * 32 *
33 * [gone - had to be deleted - what a pity] 33 * [gone - had to be deleted - what a pity]
34 * 34 *
35*/ 35*/
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$Id: rsa.c,v 1.13 2000/04/04 04:57:08 damien Exp $"); 38RCSID("$Id: rsa.c,v 1.14 2000/04/16 01:18:45 damien Exp $");
39 39
40#include "rsa.h" 40#include "rsa.h"
41#include "ssh.h" 41#include "ssh.h"
diff --git a/rsa.h b/rsa.h
index bc6c7f10a..e819c5f23 100644
--- a/rsa.h
+++ b/rsa.h
@@ -1,19 +1,19 @@
1/* 1/*
2 * 2 *
3 * rsa.h 3 * rsa.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Fri Mar 3 22:01:06 1995 ylo 10 * Created: Fri Mar 3 22:01:06 1995 ylo
11 * 11 *
12 * RSA key generation, encryption and decryption. 12 * RSA key generation, encryption and decryption.
13 * 13 *
14*/ 14*/
15 15
16/* RCSID("$Id: rsa.h,v 1.7 2000/04/13 02:26:37 damien Exp $"); */ 16/* RCSID("$Id: rsa.h,v 1.8 2000/04/16 01:18:45 damien Exp $"); */
17 17
18#ifndef RSA_H 18#ifndef RSA_H
19#define RSA_H 19#define RSA_H
diff --git a/scp.c b/scp.c
index 9f1015249..2bd3ed2bd 100644
--- a/scp.c
+++ b/scp.c
@@ -1,13 +1,13 @@
1/* 1/*
2 * 2 *
3 * scp - secure remote copy. This is basically patched BSD rcp which uses ssh 3 * scp - secure remote copy. This is basically patched BSD rcp which uses ssh
4 * to do the data transfer (instead of using rcmd). 4 * to do the data transfer (instead of using rcmd).
5 * 5 *
6 * NOTE: This version should NOT be suid root. (This uses ssh to do the transfer 6 * NOTE: This version should NOT be suid root. (This uses ssh to do the transfer
7 * and ssh has the necessary privileges.) 7 * and ssh has the necessary privileges.)
8 * 8 *
9 * 1995 Timo Rinne <tri@iki.fi>, Tatu Ylonen <ylo@cs.hut.fi> 9 * 1995 Timo Rinne <tri@iki.fi>, Tatu Ylonen <ylo@cs.hut.fi>
10 * 10 *
11*/ 11*/
12 12
13/* 13/*
@@ -45,7 +45,7 @@
45 */ 45 */
46 46
47#include "includes.h" 47#include "includes.h"
48RCSID("$Id: scp.c,v 1.18 2000/03/17 12:40:16 damien Exp $"); 48RCSID("$Id: scp.c,v 1.19 2000/04/16 01:18:45 damien Exp $");
49 49
50#include "ssh.h" 50#include "ssh.h"
51#include "xmalloc.h" 51#include "xmalloc.h"
@@ -109,7 +109,7 @@ char *port = NULL;
109 * assigns the input and output file descriptors on success. 109 * assigns the input and output file descriptors on success.
110 */ 110 */
111 111
112int 112int
113do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout) 113do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
114{ 114{
115 int pin[2], pout[2], reserved[2]; 115 int pin[2], pout[2], reserved[2];
@@ -194,7 +194,7 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
194 return 0; 194 return 0;
195} 195}
196 196
197void 197void
198fatal(const char *fmt,...) 198fatal(const char *fmt,...)
199{ 199{
200 va_list ap; 200 va_list ap;
@@ -257,10 +257,10 @@ main(argc, argv)
257 switch (ch) { 257 switch (ch) {
258 /* User-visible flags. */ 258 /* User-visible flags. */
259 case '4': 259 case '4':
260 IPv4 = 1; 260 IPv4 = 1;
261 break; 261 break;
262 case '6': 262 case '6':
263 IPv6 = 1; 263 IPv6 = 1;
264 break; 264 break;
265 case 'p': 265 case 'p':
266 pflag = 1; 266 pflag = 1;
@@ -1008,7 +1008,7 @@ run_err(const char *fmt,...)
1008 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1008 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1009 * SUCH DAMAGE. 1009 * SUCH DAMAGE.
1010 * 1010 *
1011 * $Id: scp.c,v 1.18 2000/03/17 12:40:16 damien Exp $ 1011 * $Id: scp.c,v 1.19 2000/04/16 01:18:45 damien Exp $
1012 */ 1012 */
1013 1013
1014char * 1014char *
diff --git a/servconf.c b/servconf.c
index 918fb8ed2..fe72d2757 100644
--- a/servconf.c
+++ b/servconf.c
@@ -1,18 +1,18 @@
1/* 1/*
2 * 2 *
3 * servconf.c 3 * servconf.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Mon Aug 21 15:48:58 1995 ylo 10 * Created: Mon Aug 21 15:48:58 1995 ylo
11 * 11 *
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$Id: servconf.c,v 1.11 2000/04/12 10:17:40 damien Exp $"); 15RCSID("$Id: servconf.c,v 1.12 2000/04/16 01:18:45 damien Exp $");
16 16
17#include "ssh.h" 17#include "ssh.h"
18#include "servconf.h" 18#include "servconf.h"
@@ -24,7 +24,7 @@ void add_listen_addr(ServerOptions *options, char *addr);
24 24
25/* Initializes the server options to their default values. */ 25/* Initializes the server options to their default values. */
26 26
27void 27void
28initialize_server_options(ServerOptions *options) 28initialize_server_options(ServerOptions *options)
29{ 29{
30 memset(options, 0, sizeof(*options)); 30 memset(options, 0, sizeof(*options));
@@ -73,7 +73,7 @@ initialize_server_options(ServerOptions *options)
73 options->protocol = SSH_PROTO_UNKNOWN; 73 options->protocol = SSH_PROTO_UNKNOWN;
74} 74}
75 75
76void 76void
77fill_default_server_options(ServerOptions *options) 77fill_default_server_options(ServerOptions *options)
78{ 78{
79 if (options->num_ports == 0) 79 if (options->num_ports == 0)
@@ -226,7 +226,7 @@ static struct {
226 * returns if the token is not known. 226 * returns if the token is not known.
227 */ 227 */
228 228
229static ServerOpCodes 229static ServerOpCodes
230parse_token(const char *cp, const char *filename, 230parse_token(const char *cp, const char *filename,
231 int linenum) 231 int linenum)
232{ 232{
@@ -244,7 +244,7 @@ parse_token(const char *cp, const char *filename,
244/* 244/*
245 * add listen address 245 * add listen address
246 */ 246 */
247void 247void
248add_listen_addr(ServerOptions *options, char *addr) 248add_listen_addr(ServerOptions *options, char *addr)
249{ 249{
250 extern int IPv4or6; 250 extern int IPv4or6;
@@ -274,7 +274,7 @@ add_listen_addr(ServerOptions *options, char *addr)
274 274
275/* Reads the server configuration file. */ 275/* Reads the server configuration file. */
276 276
277void 277void
278read_server_config(ServerOptions *options, const char *filename) 278read_server_config(ServerOptions *options, const char *filename)
279{ 279{
280 FILE *f; 280 FILE *f;
@@ -310,7 +310,7 @@ read_server_config(ServerOptions *options, const char *filename)
310 "ListenAdress.\n", filename, linenum); 310 "ListenAdress.\n", filename, linenum);
311 if (options->num_ports >= MAX_PORTS) 311 if (options->num_ports >= MAX_PORTS)
312 fatal("%s line %d: too many ports.\n", 312 fatal("%s line %d: too many ports.\n",
313 filename, linenum); 313 filename, linenum);
314 cp = strtok(NULL, WHITESPACE); 314 cp = strtok(NULL, WHITESPACE);
315 if (!cp) 315 if (!cp)
316 fatal("%s line %d: missing port number.\n", 316 fatal("%s line %d: missing port number.\n",
diff --git a/servconf.h b/servconf.h
index 2a3686245..b8e8163dd 100644
--- a/servconf.h
+++ b/servconf.h
@@ -1,19 +1,19 @@
1/* 1/*
2 * 2 *
3 * servconf.h 3 * servconf.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Mon Aug 21 15:35:03 1995 ylo 10 * Created: Mon Aug 21 15:35:03 1995 ylo
11 * 11 *
12 * Definitions for server configuration data and for the functions reading it. 12 * Definitions for server configuration data and for the functions reading it.
13 * 13 *
14 */ 14 */
15 15
16/* RCSID("$Id: servconf.h,v 1.8 2000/04/12 10:17:40 damien Exp $"); */ 16/* RCSID("$Id: servconf.h,v 1.9 2000/04/16 01:18:45 damien Exp $"); */
17 17
18#ifndef SERVCONF_H 18#ifndef SERVCONF_H
19#define SERVCONF_H 19#define SERVCONF_H
diff --git a/serverloop.c b/serverloop.c
index 0ea57faa0..a7abbe404 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -59,7 +59,7 @@ static volatile int child_wait_status; /* Status from wait(). */
59 59
60void server_init_dispatch(void); 60void server_init_dispatch(void);
61 61
62void 62void
63sigchld_handler(int sig) 63sigchld_handler(int sig)
64{ 64{
65 int save_errno = errno; 65 int save_errno = errno;
@@ -78,7 +78,7 @@ sigchld_handler(int sig)
78 signal(SIGCHLD, sigchld_handler); 78 signal(SIGCHLD, sigchld_handler);
79 errno = save_errno; 79 errno = save_errno;
80} 80}
81void 81void
82sigchld_handler2(int sig) 82sigchld_handler2(int sig)
83{ 83{
84 int save_errno = errno; 84 int save_errno = errno;
@@ -92,7 +92,7 @@ sigchld_handler2(int sig)
92 * Make packets from buffered stderr data, and buffer it for sending 92 * Make packets from buffered stderr data, and buffer it for sending
93 * to the client. 93 * to the client.
94 */ 94 */
95void 95void
96make_packets_from_stderr_data() 96make_packets_from_stderr_data()
97{ 97{
98 int len; 98 int len;
@@ -121,7 +121,7 @@ make_packets_from_stderr_data()
121 * Make packets from buffered stdout data, and buffer it for sending to the 121 * Make packets from buffered stdout data, and buffer it for sending to the
122 * client. 122 * client.
123 */ 123 */
124void 124void
125make_packets_from_stdout_data() 125make_packets_from_stdout_data()
126{ 126{
127 int len; 127 int len;
@@ -152,7 +152,7 @@ make_packets_from_stdout_data()
152 * have data or can accept data. Optionally, a maximum time can be specified 152 * have data or can accept data. Optionally, a maximum time can be specified
153 * for the duration of the wait (0 = infinite). 153 * for the duration of the wait (0 = infinite).
154 */ 154 */
155void 155void
156wait_until_can_do_something(fd_set * readset, fd_set * writeset, 156wait_until_can_do_something(fd_set * readset, fd_set * writeset,
157 unsigned int max_time_milliseconds) 157 unsigned int max_time_milliseconds)
158{ 158{
@@ -246,7 +246,7 @@ retry_select:
246 * Processes input from the client and the program. Input data is stored 246 * Processes input from the client and the program. Input data is stored
247 * in buffers and processed later. 247 * in buffers and processed later.
248 */ 248 */
249void 249void
250process_input(fd_set * readset) 250process_input(fd_set * readset)
251{ 251{
252 int len; 252 int len;
@@ -299,7 +299,7 @@ process_input(fd_set * readset)
299/* 299/*
300 * Sends data from internal buffers to client program stdin. 300 * Sends data from internal buffers to client program stdin.
301 */ 301 */
302void 302void
303process_output(fd_set * writeset) 303process_output(fd_set * writeset)
304{ 304{
305 int len; 305 int len;
@@ -334,7 +334,7 @@ process_output(fd_set * writeset)
334 * Wait until all buffered output has been sent to the client. 334 * Wait until all buffered output has been sent to the client.
335 * This is used when the program terminates. 335 * This is used when the program terminates.
336 */ 336 */
337void 337void
338drain_output() 338drain_output()
339{ 339{
340 /* Send any buffered stdout data to the client. */ 340 /* Send any buffered stdout data to the client. */
@@ -359,7 +359,7 @@ drain_output()
359 packet_write_wait(); 359 packet_write_wait();
360} 360}
361 361
362void 362void
363process_buffered_input_packets() 363process_buffered_input_packets()
364{ 364{
365 dispatch_run(DISPATCH_NONBLOCK, NULL); 365 dispatch_run(DISPATCH_NONBLOCK, NULL);
@@ -372,7 +372,7 @@ process_buffered_input_packets()
372 * stdin (of the child program), and reads from stdout and stderr (of the 372 * stdin (of the child program), and reads from stdout and stderr (of the
373 * child program). 373 * child program).
374 */ 374 */
375void 375void
376server_loop(int pid, int fdin_arg, int fdout_arg, int fderr_arg) 376server_loop(int pid, int fdin_arg, int fdout_arg, int fderr_arg)
377{ 377{
378 int wait_status, wait_pid; /* Status and pid returned by wait(). */ 378 int wait_status, wait_pid; /* Status and pid returned by wait(). */
@@ -604,7 +604,7 @@ server_loop(int pid, int fdin_arg, int fdout_arg, int fderr_arg)
604 /* NOTREACHED */ 604 /* NOTREACHED */
605} 605}
606 606
607void 607void
608server_loop2(void) 608server_loop2(void)
609{ 609{
610 fd_set readset, writeset; 610 fd_set readset, writeset;
@@ -697,16 +697,17 @@ int
697input_direct_tcpip(void) 697input_direct_tcpip(void)
698{ 698{
699 int sock; 699 int sock;
700 char *host, *originator; 700 char *target, *originator;
701 int host_port, originator_port; 701 int target_port, originator_port;
702 702
703 host = packet_get_string(NULL); 703 target = packet_get_string(NULL);
704 host_port = packet_get_int(); 704 target_port = packet_get_int();
705 originator = packet_get_string(NULL); 705 originator = packet_get_string(NULL);
706 originator_port = packet_get_int(); 706 originator_port = packet_get_int();
707 packet_done();
707 /* XXX check permission */ 708 /* XXX check permission */
708 sock = channel_connect_to(host, host_port); 709 sock = channel_connect_to(target, target_port);
709 xfree(host); 710 xfree(target);
710 xfree(originator); 711 xfree(originator);
711 if (sock < 0) 712 if (sock < 0)
712 return -1; 713 return -1;
@@ -714,7 +715,7 @@ input_direct_tcpip(void)
714 sock, sock, -1, 4*1024, 32*1024, 0, xstrdup("direct-tcpip")); 715 sock, sock, -1, 4*1024, 32*1024, 0, xstrdup("direct-tcpip"));
715} 716}
716 717
717void 718void
718server_input_channel_open(int type, int plen) 719server_input_channel_open(int type, int plen)
719{ 720{
720 Channel *c = NULL; 721 Channel *c = NULL;
@@ -735,6 +736,7 @@ server_input_channel_open(int type, int plen)
735 736
736 if (strcmp(ctype, "session") == 0) { 737 if (strcmp(ctype, "session") == 0) {
737 debug("open session"); 738 debug("open session");
739 packet_done();
738 /* 740 /*
739 * A server session has no fd to read or write 741 * A server session has no fd to read or write
740 * until a CHANNEL_REQUEST for a shell is made, 742 * until a CHANNEL_REQUEST for a shell is made,
@@ -783,7 +785,7 @@ server_input_channel_open(int type, int plen)
783 xfree(ctype); 785 xfree(ctype);
784} 786}
785 787
786void 788void
787server_init_dispatch_20() 789server_init_dispatch_20()
788{ 790{
789 debug("server_init_dispatch_20"); 791 debug("server_init_dispatch_20");
@@ -798,7 +800,7 @@ server_init_dispatch_20()
798 dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &channel_input_channel_request); 800 dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &channel_input_channel_request);
799 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust); 801 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust);
800} 802}
801void 803void
802server_init_dispatch_13() 804server_init_dispatch_13()
803{ 805{
804 debug("server_init_dispatch_13"); 806 debug("server_init_dispatch_13");
@@ -813,7 +815,7 @@ server_init_dispatch_13()
813 dispatch_set(SSH_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure); 815 dispatch_set(SSH_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure);
814 dispatch_set(SSH_MSG_PORT_OPEN, &channel_input_port_open); 816 dispatch_set(SSH_MSG_PORT_OPEN, &channel_input_port_open);
815} 817}
816void 818void
817server_init_dispatch_15() 819server_init_dispatch_15()
818{ 820{
819 server_init_dispatch_13(); 821 server_init_dispatch_13();
@@ -821,7 +823,7 @@ server_init_dispatch_15()
821 dispatch_set(SSH_MSG_CHANNEL_CLOSE, &channel_input_ieof); 823 dispatch_set(SSH_MSG_CHANNEL_CLOSE, &channel_input_ieof);
822 dispatch_set(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, &channel_input_oclose); 824 dispatch_set(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, &channel_input_oclose);
823} 825}
824void 826void
825server_init_dispatch() 827server_init_dispatch()
826{ 828{
827 if (compat20) 829 if (compat20)
diff --git a/session.c b/session.c
index 835a46945..8d8ff223e 100644
--- a/session.c
+++ b/session.c
@@ -8,7 +8,7 @@
8 */ 8 */
9 9
10#include "includes.h" 10#include "includes.h"
11RCSID("$OpenBSD: session.c,v 1.2 2000/04/06 08:55:22 markus Exp $"); 11RCSID("$OpenBSD: session.c,v 1.4 2000/04/14 10:30:33 markus Exp $");
12 12
13#include "xmalloc.h" 13#include "xmalloc.h"
14#include "ssh.h" 14#include "ssh.h"
@@ -113,7 +113,7 @@ xauthfile_cleanup_proc(void *ignore)
113 * Function to perform cleanup if we get aborted abnormally (e.g., due to a 113 * Function to perform cleanup if we get aborted abnormally (e.g., due to a
114 * dropped connection). 114 * dropped connection).
115 */ 115 */
116void 116void
117pty_cleanup_proc(void *session) 117pty_cleanup_proc(void *session)
118{ 118{
119 Session *s=session; 119 Session *s=session;
@@ -136,7 +136,7 @@ pty_cleanup_proc(void *session)
136 * terminals are allocated, X11, TCP/IP, and authentication agent forwardings 136 * terminals are allocated, X11, TCP/IP, and authentication agent forwardings
137 * are requested, etc. 137 * are requested, etc.
138 */ 138 */
139void 139void
140do_authenticated(struct passwd * pw) 140do_authenticated(struct passwd * pw)
141{ 141{
142 Session *s; 142 Session *s;
@@ -366,7 +366,7 @@ do_authenticated(struct passwd * pw)
366 * will call do_child from the child, and server_loop from the parent after 366 * will call do_child from the child, and server_loop from the parent after
367 * setting up file descriptors and such. 367 * setting up file descriptors and such.
368 */ 368 */
369void 369void
370do_exec_no_pty(Session *s, const char *command, struct passwd * pw) 370do_exec_no_pty(Session *s, const char *command, struct passwd * pw)
371{ 371{
372 int pid; 372 int pid;
@@ -487,7 +487,7 @@ do_exec_no_pty(Session *s, const char *command, struct passwd * pw)
487 * setting up file descriptors, controlling tty, updating wtmp, utmp, 487 * setting up file descriptors, controlling tty, updating wtmp, utmp,
488 * lastlog, and other such operations. 488 * lastlog, and other such operations.
489 */ 489 */
490void 490void
491do_exec_pty(Session *s, const char *command, struct passwd * pw) 491do_exec_pty(Session *s, const char *command, struct passwd * pw)
492{ 492{
493 FILE *f; 493 FILE *f;
@@ -660,7 +660,7 @@ do_exec_pty(Session *s, const char *command, struct passwd * pw)
660 * Sets the value of the given variable in the environment. If the variable 660 * Sets the value of the given variable in the environment. If the variable
661 * already exists, its value is overriden. 661 * already exists, its value is overriden.
662 */ 662 */
663void 663void
664child_set_env(char ***envp, unsigned int *envsizep, const char *name, 664child_set_env(char ***envp, unsigned int *envsizep, const char *name,
665 const char *value) 665 const char *value)
666{ 666{
@@ -701,7 +701,7 @@ child_set_env(char ***envp, unsigned int *envsizep, const char *name,
701 * Otherwise, it must consist of empty lines, comments (line starts with '#') 701 * Otherwise, it must consist of empty lines, comments (line starts with '#')
702 * and assignments of the form name=value. No other forms are allowed. 702 * and assignments of the form name=value. No other forms are allowed.
703 */ 703 */
704void 704void
705read_environment_file(char ***env, unsigned int *envsize, 705read_environment_file(char ***env, unsigned int *envsize,
706 const char *filename) 706 const char *filename)
707{ 707{
@@ -770,7 +770,7 @@ void do_pam_environment(char ***env, int *envsize)
770 * environment, closing extra file descriptors, setting the user and group 770 * environment, closing extra file descriptors, setting the user and group
771 * ids, and executing the command or shell. 771 * ids, and executing the command or shell.
772 */ 772 */
773void 773void
774do_child(const char *command, struct passwd * pw, const char *term, 774do_child(const char *command, struct passwd * pw, const char *term,
775 const char *display, const char *auth_proto, 775 const char *display, const char *auth_proto,
776 const char *auth_data, const char *ttyname) 776 const char *auth_data, const char *ttyname)
@@ -1202,6 +1202,7 @@ session_window_change_req(Session *s)
1202 s->row = packet_get_int(); 1202 s->row = packet_get_int();
1203 s->xpixel = packet_get_int(); 1203 s->xpixel = packet_get_int();
1204 s->ypixel = packet_get_int(); 1204 s->ypixel = packet_get_int();
1205 packet_done();
1205 pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); 1206 pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel);
1206 return 1; 1207 return 1;
1207} 1208}
@@ -1210,14 +1211,17 @@ int
1210session_pty_req(Session *s) 1211session_pty_req(Session *s)
1211{ 1212{
1212 unsigned int len; 1213 unsigned int len;
1214 char *term_modes; /* encoded terminal modes */
1213 1215
1214 if (s->ttyfd != -1) 1216 if (s->ttyfd != -1)
1215 return -1; 1217 return 0;
1216 s->term = packet_get_string(&len); 1218 s->term = packet_get_string(&len);
1217 s->col = packet_get_int(); 1219 s->col = packet_get_int();
1218 s->row = packet_get_int(); 1220 s->row = packet_get_int();
1219 s->xpixel = packet_get_int(); 1221 s->xpixel = packet_get_int();
1220 s->ypixel = packet_get_int(); 1222 s->ypixel = packet_get_int();
1223 term_modes = packet_get_string(&len);
1224 packet_done();
1221 1225
1222 if (strcmp(s->term, "") == 0) { 1226 if (strcmp(s->term, "") == 0) {
1223 xfree(s->term); 1227 xfree(s->term);
@@ -1230,7 +1234,8 @@ session_pty_req(Session *s)
1230 s->ptyfd = -1; 1234 s->ptyfd = -1;
1231 s->ttyfd = -1; 1235 s->ttyfd = -1;
1232 error("session_pty_req: session %d alloc failed", s->self); 1236 error("session_pty_req: session %d alloc failed", s->self);
1233 return -1; 1237 xfree(term_modes);
1238 return 0;
1234 } 1239 }
1235 debug("session_pty_req: session %d alloc %s", s->self, s->tty); 1240 debug("session_pty_req: session %d alloc %s", s->self, s->tty);
1236 /* 1241 /*
diff --git a/ssh-agent.c b/ssh-agent.c
index ecb44a229..66439461e 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-agent.c,v 1.27 2000/04/12 09:39:10 markus Exp $ */ 1/* $OpenBSD: ssh-agent.c,v 1.28 2000/04/14 10:30:33 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -9,7 +9,7 @@
9 */ 9 */
10 10
11#include "includes.h" 11#include "includes.h"
12RCSID("$OpenBSD: ssh-agent.c,v 1.27 2000/04/12 09:39:10 markus Exp $"); 12RCSID("$OpenBSD: ssh-agent.c,v 1.28 2000/04/14 10:30:33 markus Exp $");
13 13
14#include "ssh.h" 14#include "ssh.h"
15#include "rsa.h" 15#include "rsa.h"
@@ -412,7 +412,7 @@ prepare_select(fd_set *readset, fd_set *writeset)
412 } 412 }
413} 413}
414 414
415void 415void
416after_select(fd_set *readset, fd_set *writeset) 416after_select(fd_set *readset, fd_set *writeset)
417{ 417{
418 unsigned int i; 418 unsigned int i;
@@ -646,8 +646,8 @@ main(int ac, char **av)
646 } 646 }
647 signal(SIGINT, SIG_IGN); 647 signal(SIGINT, SIG_IGN);
648 signal(SIGPIPE, SIG_IGN); 648 signal(SIGPIPE, SIG_IGN);
649 signal(SIGHUP, cleanup_exit); 649 signal(SIGHUP, cleanup_exit);
650 signal(SIGTERM, cleanup_exit); 650 signal(SIGTERM, cleanup_exit);
651 while (1) { 651 while (1) {
652 FD_ZERO(&readset); 652 FD_ZERO(&readset);
653 FD_ZERO(&writeset); 653 FD_ZERO(&writeset);
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 81070d2ef..f2484a4b1 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9#include "includes.h" 9#include "includes.h"
10RCSID("$Id: ssh-keygen.c,v 1.12 2000/03/17 12:40:17 damien Exp $"); 10RCSID("$Id: ssh-keygen.c,v 1.13 2000/04/16 01:18:46 damien Exp $");
11 11
12#include "rsa.h" 12#include "rsa.h"
13#include "ssh.h" 13#include "ssh.h"
@@ -508,7 +508,7 @@ passphrase_again:
508 if (identity_comment) { 508 if (identity_comment) {
509 strlcpy(comment, identity_comment, sizeof(comment)); 509 strlcpy(comment, identity_comment, sizeof(comment));
510 } else { 510 } else {
511 /* Create default commend field for the passphrase. */ 511 /* Create default commend field for the passphrase. */
512 if (gethostname(hostname, sizeof(hostname)) < 0) { 512 if (gethostname(hostname, sizeof(hostname)) < 0) {
513 perror("gethostname"); 513 perror("gethostname");
514 exit(1); 514 exit(1);
diff --git a/ssh.1 b/ssh.1
index 548339e6b..1d1a76cf7 100644
--- a/ssh.1
+++ b/ssh.1
@@ -9,7 +9,7 @@
9.\" 9.\"
10.\" Created: Sat Apr 22 21:55:14 1995 ylo 10.\" Created: Sat Apr 22 21:55:14 1995 ylo
11.\" 11.\"
12.\" $Id: ssh.1,v 1.21 2000/04/13 02:26:37 damien Exp $ 12.\" $Id: ssh.1,v 1.22 2000/04/16 01:18:46 damien Exp $
13.\" 13.\"
14.Dd September 25, 1999 14.Dd September 25, 1999
15.Dt SSH 1 15.Dt SSH 1
@@ -24,7 +24,7 @@
24.Op Ar command 24.Op Ar command
25.Pp 25.Pp
26.Nm ssh 26.Nm ssh
27.Op Fl afgknqtvxCPX46 27.Op Fl afgknqtvxCPX246
28.Op Fl c Ar blowfish | 3des 28.Op Fl c Ar blowfish | 3des
29.Op Fl e Ar escape_char 29.Op Fl e Ar escape_char
30.Op Fl i Ar identity_file 30.Op Fl i Ar identity_file
@@ -455,6 +455,10 @@ from the local machine.
455Port forwardings can also be specified in the configuration file. 455Port forwardings can also be specified in the configuration file.
456Privileged ports can be forwarded only when 456Privileged ports can be forwarded only when
457logging in as root on the remote machine. 457logging in as root on the remote machine.
458.It Fl 2
459Forces
460.Nm
461to use protocol version 2 only.
458.It Fl 4 462.It Fl 4
459Forces 463Forces
460.Nm 464.Nm
diff --git a/ssh.c b/ssh.c
index f23694247..456570fc4 100644
--- a/ssh.c
+++ b/ssh.c
@@ -11,7 +11,7 @@
11 */ 11 */
12 12
13#include "includes.h" 13#include "includes.h"
14RCSID("$Id: ssh.c,v 1.25 2000/04/12 10:17:40 damien Exp $"); 14RCSID("$Id: ssh.c,v 1.26 2000/04/16 01:18:46 damien Exp $");
15 15
16#include "xmalloc.h" 16#include "xmalloc.h"
17#include "ssh.h" 17#include "ssh.h"
@@ -138,6 +138,7 @@ usage()
138 fprintf(stderr, " -g Allow remote hosts to connect to forwarded ports.\n"); 138 fprintf(stderr, " -g Allow remote hosts to connect to forwarded ports.\n");
139 fprintf(stderr, " -4 Use IPv4 only.\n"); 139 fprintf(stderr, " -4 Use IPv4 only.\n");
140 fprintf(stderr, " -6 Use IPv6 only.\n"); 140 fprintf(stderr, " -6 Use IPv6 only.\n");
141 fprintf(stderr, " -2 Force protocol version 2.\n");
141 fprintf(stderr, " -o 'option' Process the option as if it was read from a configuration file.\n"); 142 fprintf(stderr, " -o 'option' Process the option as if it was read from a configuration file.\n");
142 exit(1); 143 exit(1);
143} 144}
@@ -251,8 +252,8 @@ main(int ac, char **av)
251 if (host) 252 if (host)
252 break; 253 break;
253 if ((cp = strchr(av[optind], '@'))) { 254 if ((cp = strchr(av[optind], '@'))) {
254 if(cp == av[optind]) 255 if(cp == av[optind])
255 usage(); 256 usage();
256 options.user = av[optind]; 257 options.user = av[optind];
257 *cp = '\0'; 258 *cp = '\0';
258 host = ++cp; 259 host = ++cp;
@@ -276,39 +277,34 @@ main(int ac, char **av)
276 optarg = NULL; 277 optarg = NULL;
277 } 278 }
278 switch (opt) { 279 switch (opt) {
280 case '2':
281 options.protocol = SSH_PROTO_2;
282 break;
279 case '4': 283 case '4':
280 IPv4or6 = AF_INET; 284 IPv4or6 = AF_INET;
281 break; 285 break;
282
283 case '6': 286 case '6':
284 IPv4or6 = AF_INET6; 287 IPv4or6 = AF_INET6;
285 break; 288 break;
286
287 case 'n': 289 case 'n':
288 stdin_null_flag = 1; 290 stdin_null_flag = 1;
289 break; 291 break;
290
291 case 'f': 292 case 'f':
292 fork_after_authentication_flag = 1; 293 fork_after_authentication_flag = 1;
293 stdin_null_flag = 1; 294 stdin_null_flag = 1;
294 break; 295 break;
295
296 case 'x': 296 case 'x':
297 options.forward_x11 = 0; 297 options.forward_x11 = 0;
298 break; 298 break;
299
300 case 'X': 299 case 'X':
301 options.forward_x11 = 1; 300 options.forward_x11 = 1;
302 break; 301 break;
303
304 case 'g': 302 case 'g':
305 options.gateway_ports = 1; 303 options.gateway_ports = 1;
306 break; 304 break;
307
308 case 'P': 305 case 'P':
309 options.use_privileged_port = 0; 306 options.use_privileged_port = 0;
310 break; 307 break;
311
312 case 'a': 308 case 'a':
313 options.forward_agent = 0; 309 options.forward_agent = 0;
314 break; 310 break;
@@ -330,11 +326,9 @@ main(int ac, char **av)
330 options.identity_files[options.num_identity_files++] = 326 options.identity_files[options.num_identity_files++] =
331 xstrdup(optarg); 327 xstrdup(optarg);
332 break; 328 break;
333
334 case 't': 329 case 't':
335 tty_flag = 1; 330 tty_flag = 1;
336 break; 331 break;
337
338 case 'v': 332 case 'v':
339 case 'V': 333 case 'V':
340 fprintf(stderr, "SSH Version %s, protocol versions %d.%d/%d.%d.\n", 334 fprintf(stderr, "SSH Version %s, protocol versions %d.%d/%d.%d.\n",
@@ -347,11 +341,9 @@ main(int ac, char **av)
347 debug_flag = 1; 341 debug_flag = 1;
348 options.log_level = SYSLOG_LEVEL_DEBUG; 342 options.log_level = SYSLOG_LEVEL_DEBUG;
349 break; 343 break;
350
351 case 'q': 344 case 'q':
352 options.log_level = SYSLOG_LEVEL_QUIET; 345 options.log_level = SYSLOG_LEVEL_QUIET;
353 break; 346 break;
354
355 case 'e': 347 case 'e':
356 if (optarg[0] == '^' && optarg[2] == 0 && 348 if (optarg[0] == '^' && optarg[2] == 0 &&
357 (unsigned char) optarg[1] >= 64 && (unsigned char) optarg[1] < 128) 349 (unsigned char) optarg[1] >= 64 && (unsigned char) optarg[1] < 128)
@@ -365,7 +357,6 @@ main(int ac, char **av)
365 exit(1); 357 exit(1);
366 } 358 }
367 break; 359 break;
368
369 case 'c': 360 case 'c':
370 options.cipher = cipher_number(optarg); 361 options.cipher = cipher_number(optarg);
371 if (options.cipher == -1) { 362 if (options.cipher == -1) {
@@ -373,15 +364,12 @@ main(int ac, char **av)
373 exit(1); 364 exit(1);
374 } 365 }
375 break; 366 break;
376
377 case 'p': 367 case 'p':
378 options.port = atoi(optarg); 368 options.port = atoi(optarg);
379 break; 369 break;
380
381 case 'l': 370 case 'l':
382 options.user = optarg; 371 options.user = optarg;
383 break; 372 break;
384
385 case 'R': 373 case 'R':
386 if (sscanf(optarg, "%hu/%255[^/]/%hu", &fwd_port, buf, 374 if (sscanf(optarg, "%hu/%255[^/]/%hu", &fwd_port, buf,
387 &fwd_host_port) != 3 && 375 &fwd_host_port) != 3 &&
@@ -393,7 +381,6 @@ main(int ac, char **av)
393 } 381 }
394 add_remote_forward(&options, fwd_port, buf, fwd_host_port); 382 add_remote_forward(&options, fwd_port, buf, fwd_host_port);
395 break; 383 break;
396
397 case 'L': 384 case 'L':
398 if (sscanf(optarg, "%hu/%255[^/]/%hu", &fwd_port, buf, 385 if (sscanf(optarg, "%hu/%255[^/]/%hu", &fwd_port, buf,
399 &fwd_host_port) != 3 && 386 &fwd_host_port) != 3 &&
@@ -405,27 +392,22 @@ main(int ac, char **av)
405 } 392 }
406 add_local_forward(&options, fwd_port, buf, fwd_host_port); 393 add_local_forward(&options, fwd_port, buf, fwd_host_port);
407 break; 394 break;
408
409 case 'C': 395 case 'C':
410 options.compression = 1; 396 options.compression = 1;
411 break; 397 break;
412
413 case 'N': 398 case 'N':
414 no_shell_flag = 1; 399 no_shell_flag = 1;
415 no_tty_flag = 1; 400 no_tty_flag = 1;
416 break; 401 break;
417
418 case 'T': 402 case 'T':
419 no_tty_flag = 1; 403 no_tty_flag = 1;
420 break; 404 break;
421
422 case 'o': 405 case 'o':
423 dummy = 1; 406 dummy = 1;
424 if (process_config_line(&options, host ? host : "", optarg, 407 if (process_config_line(&options, host ? host : "", optarg,
425 "command-line", 0, &dummy) != 0) 408 "command-line", 0, &dummy) != 0)
426 exit(1); 409 exit(1);
427 break; 410 break;
428
429 default: 411 default:
430 usage(); 412 usage();
431 } 413 }
@@ -634,7 +616,7 @@ main(int ac, char **av)
634 616
635 /* Expand ~ in known host file names. */ 617 /* Expand ~ in known host file names. */
636 options.system_hostfile = tilde_expand_filename(options.system_hostfile, 618 options.system_hostfile = tilde_expand_filename(options.system_hostfile,
637 original_real_uid); 619 original_real_uid);
638 options.user_hostfile = tilde_expand_filename(options.user_hostfile, 620 options.user_hostfile = tilde_expand_filename(options.user_hostfile,
639 original_real_uid); 621 original_real_uid);
640 622
@@ -803,7 +785,7 @@ ssh_session(void)
803 options.local_forwards[i].host, 785 options.local_forwards[i].host,
804 options.local_forwards[i].host_port); 786 options.local_forwards[i].host_port);
805 channel_request_local_forwarding(options.local_forwards[i].port, 787 channel_request_local_forwarding(options.local_forwards[i].port,
806 options.local_forwards[i].host, 788 options.local_forwards[i].host,
807 options.local_forwards[i].host_port, 789 options.local_forwards[i].host_port,
808 options.gateway_ports); 790 options.gateway_ports);
809 } 791 }
@@ -816,11 +798,11 @@ ssh_session(void)
816 options.remote_forwards[i].host_port); 798 options.remote_forwards[i].host_port);
817 channel_request_remote_forwarding(options.remote_forwards[i].port, 799 channel_request_remote_forwarding(options.remote_forwards[i].port,
818 options.remote_forwards[i].host, 800 options.remote_forwards[i].host,
819 options.remote_forwards[i].host_port); 801 options.remote_forwards[i].host_port);
820 } 802 }
821 803
822 /* If requested, let ssh continue in the background. */ 804 /* If requested, let ssh continue in the background. */
823 if (fork_after_authentication_flag) 805 if (fork_after_authentication_flag)
824 if (daemon(1, 1) < 0) 806 if (daemon(1, 1) < 0)
825 fatal("daemon() failed: %.200s", strerror(errno)); 807 fatal("daemon() failed: %.200s", strerror(errno));
826 808
@@ -859,7 +841,7 @@ init_local_fwd(void)
859 options.local_forwards[i].host, 841 options.local_forwards[i].host,
860 options.local_forwards[i].host_port); 842 options.local_forwards[i].host_port);
861 channel_request_local_forwarding(options.local_forwards[i].port, 843 channel_request_local_forwarding(options.local_forwards[i].port,
862 options.local_forwards[i].host, 844 options.local_forwards[i].host,
863 options.local_forwards[i].host_port, 845 options.local_forwards[i].host_port,
864 options.gateway_ports); 846 options.gateway_ports);
865 } 847 }
diff --git a/ssh.h b/ssh.h
index ea2dc032c..57fcf57b9 100644
--- a/ssh.h
+++ b/ssh.h
@@ -1,19 +1,19 @@
1/* 1/*
2 * 2 *
3 * ssh.h 3 * ssh.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Fri Mar 17 17:09:37 1995 ylo 10 * Created: Fri Mar 17 17:09:37 1995 ylo
11 * 11 *
12 * Generic header file for ssh. 12 * Generic header file for ssh.
13 * 13 *
14 */ 14 */
15 15
16/* RCSID("$Id: ssh.h,v 1.31 2000/04/12 10:17:41 damien Exp $"); */ 16/* RCSID("$Id: ssh.h,v 1.32 2000/04/16 01:18:47 damien Exp $"); */
17 17
18#ifndef SSH_H 18#ifndef SSH_H
19#define SSH_H 19#define SSH_H
@@ -279,7 +279,7 @@
279 * information is not available. This must be called before record_login. 279 * information is not available. This must be called before record_login.
280 * The host from which the user logged in is stored in buf. 280 * The host from which the user logged in is stored in buf.
281 */ 281 */
282unsigned long 282unsigned long
283get_last_login_time(uid_t uid, const char *logname, 283get_last_login_time(uid_t uid, const char *logname,
284 char *buf, unsigned int bufsize); 284 char *buf, unsigned int bufsize);
285 285
@@ -287,7 +287,7 @@ get_last_login_time(uid_t uid, const char *logname,
287 * Records that the user has logged in. This does many things normally done 287 * Records that the user has logged in. This does many things normally done
288 * by login(1). 288 * by login(1).
289 */ 289 */
290void 290void
291record_login(int pid, const char *ttyname, const char *user, uid_t uid, 291record_login(int pid, const char *ttyname, const char *user, uid_t uid,
292 const char *host, struct sockaddr *addr); 292 const char *host, struct sockaddr *addr);
293 293
@@ -308,7 +308,7 @@ void record_logout(int pid, const char *ttyname);
308 * and zero on failure. If the connection is successful, this calls 308 * and zero on failure. If the connection is successful, this calls
309 * packet_set_connection for the connection. 309 * packet_set_connection for the connection.
310 */ 310 */
311int 311int
312ssh_connect(const char *host, struct sockaddr_storage * hostaddr, 312ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
313 u_short port, int connection_attempts, 313 u_short port, int connection_attempts,
314 int anonymous, uid_t original_real_uid, 314 int anonymous, uid_t original_real_uid,
@@ -323,7 +323,7 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
323 * references from the packet module). 323 * references from the packet module).
324 */ 324 */
325 325
326void 326void
327ssh_login(int host_key_valid, RSA * host_key, const char *host, 327ssh_login(int host_key_valid, RSA * host_key, const char *host,
328 struct sockaddr * hostaddr, uid_t original_real_uid); 328 struct sockaddr * hostaddr, uid_t original_real_uid);
329 329
@@ -340,7 +340,7 @@ int auth_rhosts(struct passwd * pw, const char *client_user);
340 * Tries to authenticate the user using the .rhosts file and the host using 340 * Tries to authenticate the user using the .rhosts file and the host using
341 * its host key. Returns true if authentication succeeds. 341 * its host key. Returns true if authentication succeeds.
342 */ 342 */
343int 343int
344auth_rhosts_rsa(struct passwd * pw, const char *client_user, RSA* client_host_key); 344auth_rhosts_rsa(struct passwd * pw, const char *client_user, RSA* client_host_key);
345 345
346/* 346/*
@@ -409,7 +409,7 @@ char *read_passphrase(const char *prompt, int from_stdin);
409 * precede the key to provide identification of the key without needing a 409 * precede the key to provide identification of the key without needing a
410 * passphrase. 410 * passphrase.
411 */ 411 */
412int 412int
413save_private_key(const char *filename, const char *passphrase, 413save_private_key(const char *filename, const char *passphrase,
414 RSA * private_key, const char *comment); 414 RSA * private_key, const char *comment);
415 415
@@ -419,7 +419,7 @@ save_private_key(const char *filename, const char *passphrase,
419 * comment of the key is returned in comment_return if it is non-NULL; the 419 * comment of the key is returned in comment_return if it is non-NULL; the
420 * caller must free the value with xfree. 420 * caller must free the value with xfree.
421 */ 421 */
422int 422int
423load_public_key(const char *filename, RSA * pub, 423load_public_key(const char *filename, RSA * pub,
424 char **comment_return); 424 char **comment_return);
425 425
@@ -430,7 +430,7 @@ load_public_key(const char *filename, RSA * pub,
430 * comment_return if it is non-NULL; the caller must free the value with 430 * comment_return if it is non-NULL; the caller must free the value with
431 * xfree. 431 * xfree.
432 */ 432 */
433int 433int
434load_private_key(const char *filename, const char *passphrase, 434load_private_key(const char *filename, const char *passphrase,
435 RSA * private_key, char **comment_return); 435 RSA * private_key, char **comment_return);
436 436
diff --git a/ssh2.h b/ssh2.h
index cc659f847..cf684bacf 100644
--- a/ssh2.h
+++ b/ssh2.h
@@ -1,31 +1,31 @@
1/* 1/*
2 * draft-ietf-secsh-architecture-04.txt 2 * draft-ietf-secsh-architecture-04.txt
3 * 3 *
4 * Transport layer protocol: 4 * Transport layer protocol:
5 * 5 *
6 * 1-19 Transport layer generic (e.g. disconnect, ignore, debug, 6 * 1-19 Transport layer generic (e.g. disconnect, ignore, debug,
7 * etc) 7 * etc)
8 * 20-29 Algorithm negotiation 8 * 20-29 Algorithm negotiation
9 * 30-49 Key exchange method specific (numbers can be reused for 9 * 30-49 Key exchange method specific (numbers can be reused for
10 * different authentication methods) 10 * different authentication methods)
11 * 11 *
12 * User authentication protocol: 12 * User authentication protocol:
13 * 13 *
14 * 50-59 User authentication generic 14 * 50-59 User authentication generic
15 * 60-79 User authentication method specific (numbers can be reused 15 * 60-79 User authentication method specific (numbers can be reused
16 * for different authentication methods) 16 * for different authentication methods)
17 * 17 *
18 * Connection protocol: 18 * Connection protocol:
19 * 19 *
20 * 80-89 Connection protocol generic 20 * 80-89 Connection protocol generic
21 * 90-127 Channel related messages 21 * 90-127 Channel related messages
22 * 22 *
23 * Reserved for client protocols: 23 * Reserved for client protocols:
24 * 24 *
25 * 128-191 Reserved 25 * 128-191 Reserved
26 * 26 *
27 * Local extensions: 27 * Local extensions:
28 * 28 *
29 * 192-255 Local extensions 29 * 192-255 Local extensions
30 */ 30 */
31 31
diff --git a/sshconnect.c b/sshconnect.c
index 675de6102..bca0bf43a 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -10,7 +10,7 @@
10 */ 10 */
11 11
12#include "includes.h" 12#include "includes.h"
13RCSID("$OpenBSD: sshconnect.c,v 1.66 2000/04/12 09:39:10 markus Exp $"); 13RCSID("$OpenBSD: sshconnect.c,v 1.68 2000/04/14 10:30:33 markus Exp $");
14 14
15#ifdef HAVE_OPENSSL 15#ifdef HAVE_OPENSSL
16#include <openssl/bn.h> 16#include <openssl/bn.h>
@@ -250,7 +250,7 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
250 debug("Trying again..."); 250 debug("Trying again...");
251 251
252 /* Loop through addresses for this host, and try each one in 252 /* Loop through addresses for this host, and try each one in
253 sequence until the connection succeeds. */ 253 sequence until the connection succeeds. */
254 for (ai = aitop; ai; ai = ai->ai_next) { 254 for (ai = aitop; ai; ai = ai->ai_next) {
255 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) 255 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
256 continue; 256 continue;
@@ -264,7 +264,7 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
264 host, ntop, strport); 264 host, ntop, strport);
265 265
266 /* Create a socket for connecting. */ 266 /* Create a socket for connecting. */
267 sock = ssh_create_socket(original_real_uid, 267 sock = ssh_create_socket(original_real_uid,
268 !anonymous && geteuid() == 0 && port < IPPORT_RESERVED, 268 !anonymous && geteuid() == 0 && port < IPPORT_RESERVED,
269 ai->ai_family); 269 ai->ai_family);
270 if (sock < 0) 270 if (sock < 0)
@@ -1059,7 +1059,7 @@ ssh_exchange_identification()
1059 break; 1059 break;
1060 } 1060 }
1061 /* FALLTHROUGH */ 1061 /* FALLTHROUGH */
1062 default: 1062 default:
1063 mismatch = 1; 1063 mismatch = 1;
1064 break; 1064 break;
1065 } 1065 }
@@ -1363,13 +1363,13 @@ ssh_kex2(char *host, struct sockaddr *hostaddr)
1363 1363
1364 debug("Sending KEX init."); 1364 debug("Sending KEX init.");
1365 if (options.ciphers != NULL) { 1365 if (options.ciphers != NULL) {
1366 myproposal[PROPOSAL_ENC_ALGS_CTOS] = 1366 myproposal[PROPOSAL_ENC_ALGS_CTOS] =
1367 myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers; 1367 myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers;
1368 } else if ( 1368 } else if (
1369 options.cipher == SSH_CIPHER_ARCFOUR || 1369 options.cipher == SSH_CIPHER_ARCFOUR ||
1370 options.cipher == SSH_CIPHER_3DES_CBC || 1370 options.cipher == SSH_CIPHER_3DES_CBC ||
1371 options.cipher == SSH_CIPHER_CAST128_CBC || 1371 options.cipher == SSH_CIPHER_CAST128_CBC ||
1372 options.cipher == SSH_CIPHER_BLOWFISH_CBC) { 1372 options.cipher == SSH_CIPHER_BLOWFISH_CBC) {
1373 myproposal[PROPOSAL_ENC_ALGS_CTOS] = 1373 myproposal[PROPOSAL_ENC_ALGS_CTOS] =
1374 myproposal[PROPOSAL_ENC_ALGS_STOC] = cipher_name(options.cipher); 1374 myproposal[PROPOSAL_ENC_ALGS_STOC] = cipher_name(options.cipher);
1375 } 1375 }
@@ -1411,6 +1411,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr)
1411 debug("first kex follow == %d", i); 1411 debug("first kex follow == %d", i);
1412 i = packet_get_int(); 1412 i = packet_get_int();
1413 debug("reserved == %d", i); 1413 debug("reserved == %d", i);
1414 packet_done();
1414 1415
1415 debug("done read kexinit"); 1416 debug("done read kexinit");
1416 kex = kex_choose_conf(cprop, sprop, 0); 1417 kex = kex_choose_conf(cprop, sprop, 0);
@@ -1434,7 +1435,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr)
1434 fprintf(stderr, "\npub= "); 1435 fprintf(stderr, "\npub= ");
1435 bignum_print(dh->pub_key); 1436 bignum_print(dh->pub_key);
1436 fprintf(stderr, "\n"); 1437 fprintf(stderr, "\n");
1437 DHparams_print_fp(stderr, dh); 1438 DHparams_print_fp(stderr, dh);
1438#endif 1439#endif
1439 1440
1440 debug("Wait SSH2_MSG_KEXDH_REPLY."); 1441 debug("Wait SSH2_MSG_KEXDH_REPLY.");
@@ -1466,6 +1467,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr)
1466 1467
1467 /* signed H */ 1468 /* signed H */
1468 signature = packet_get_string(&slen); 1469 signature = packet_get_string(&slen);
1470 packet_done();
1469 1471
1470 if (!dh_pub_is_valid(dh, dh_server_pub)) 1472 if (!dh_pub_is_valid(dh, dh_server_pub))
1471 packet_disconnect("bad server public DH value"); 1473 packet_disconnect("bad server public DH value");
@@ -1475,14 +1477,14 @@ ssh_kex2(char *host, struct sockaddr *hostaddr)
1475 kout = DH_compute_key(kbuf, dh_server_pub, dh); 1477 kout = DH_compute_key(kbuf, dh_server_pub, dh);
1476#ifdef DEBUG_KEXDH 1478#ifdef DEBUG_KEXDH
1477 debug("shared secret: len %d/%d", klen, kout); 1479 debug("shared secret: len %d/%d", klen, kout);
1478 fprintf(stderr, "shared secret == "); 1480 fprintf(stderr, "shared secret == ");
1479 for (i = 0; i< kout; i++) 1481 for (i = 0; i< kout; i++)
1480 fprintf(stderr, "%02x", (kbuf[i])&0xff); 1482 fprintf(stderr, "%02x", (kbuf[i])&0xff);
1481 fprintf(stderr, "\n"); 1483 fprintf(stderr, "\n");
1482#endif 1484#endif
1483 shared_secret = BN_new(); 1485 shared_secret = BN_new();
1484 1486
1485 BN_bin2bn(kbuf, kout, shared_secret); 1487 BN_bin2bn(kbuf, kout, shared_secret);
1486 memset(kbuf, 0, klen); 1488 memset(kbuf, 0, klen);
1487 xfree(kbuf); 1489 xfree(kbuf);
1488 1490
@@ -1502,10 +1504,10 @@ ssh_kex2(char *host, struct sockaddr *hostaddr)
1502 xfree(client_kexinit); 1504 xfree(client_kexinit);
1503 xfree(server_kexinit); 1505 xfree(server_kexinit);
1504#ifdef DEBUG_KEXDH 1506#ifdef DEBUG_KEXDH
1505 fprintf(stderr, "hash == "); 1507 fprintf(stderr, "hash == ");
1506 for (i = 0; i< 20; i++) 1508 for (i = 0; i< 20; i++)
1507 fprintf(stderr, "%02x", (hash[i])&0xff); 1509 fprintf(stderr, "%02x", (hash[i])&0xff);
1508 fprintf(stderr, "\n"); 1510 fprintf(stderr, "\n");
1509#endif 1511#endif
1510 dsa_verify(server_host_key, (unsigned char *)signature, slen, hash, 20); 1512 dsa_verify(server_host_key, (unsigned char *)signature, slen, hash, 20);
1511 key_free(server_host_key); 1513 key_free(server_host_key);
@@ -1518,6 +1520,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr)
1518 1520
1519 debug("Wait SSH2_MSG_NEWKEYS."); 1521 debug("Wait SSH2_MSG_NEWKEYS.");
1520 packet_read_expect(&payload_len, SSH2_MSG_NEWKEYS); 1522 packet_read_expect(&payload_len, SSH2_MSG_NEWKEYS);
1523 packet_done();
1521 debug("GOT SSH2_MSG_NEWKEYS."); 1524 debug("GOT SSH2_MSG_NEWKEYS.");
1522 1525
1523 debug("send SSH2_MSG_NEWKEYS."); 1526 debug("send SSH2_MSG_NEWKEYS.");
@@ -1551,7 +1554,7 @@ ssh_userauth2(int host_key_valid, RSA *own_host_key,
1551 char *server_user, *local_user; 1554 char *server_user, *local_user;
1552 char *auths; 1555 char *auths;
1553 char *password; 1556 char *password;
1554 char *service = "ssh-connection"; // service name 1557 char *service = "ssh-connection"; /* service name */
1555 1558
1556 debug("send SSH2_MSG_SERVICE_REQUEST"); 1559 debug("send SSH2_MSG_SERVICE_REQUEST");
1557 packet_start(SSH2_MSG_SERVICE_REQUEST); 1560 packet_start(SSH2_MSG_SERVICE_REQUEST);
@@ -1563,8 +1566,15 @@ ssh_userauth2(int host_key_valid, RSA *own_host_key,
1563 if (type != SSH2_MSG_SERVICE_ACCEPT) { 1566 if (type != SSH2_MSG_SERVICE_ACCEPT) {
1564 fatal("denied SSH2_MSG_SERVICE_ACCEPT: %d", type); 1567 fatal("denied SSH2_MSG_SERVICE_ACCEPT: %d", type);
1565 } 1568 }
1566 /* payload empty for ssh-2.0.13 ?? */ 1569 if (packet_remaining() > 0) {
1567 /* reply = packet_get_string(&payload_len); */ 1570 char *reply = packet_get_string(&plen);
1571 debug("service_accept: %s", reply);
1572 xfree(reply);
1573 } else {
1574 /* payload empty for ssh-2.0.13 ?? */
1575 log("buggy server: service_accept w/o service");
1576 }
1577 packet_done();
1568 debug("got SSH2_MSG_SERVICE_ACCEPT"); 1578 debug("got SSH2_MSG_SERVICE_ACCEPT");
1569 1579
1570 /*XX COMMONCODE: */ 1580 /*XX COMMONCODE: */
@@ -1593,6 +1603,7 @@ ssh_userauth2(int host_key_valid, RSA *own_host_key,
1593 auths = packet_get_string(&dlen); 1603 auths = packet_get_string(&dlen);
1594 debug("authentications that can continue: %s", auths); 1604 debug("authentications that can continue: %s", auths);
1595 partial = packet_get_char(); 1605 partial = packet_get_char();
1606 packet_done();
1596 if (partial) 1607 if (partial)
1597 debug("partial success"); 1608 debug("partial success");
1598 if (strstr(auths, "password") == NULL) 1609 if (strstr(auths, "password") == NULL)
@@ -1613,6 +1624,7 @@ ssh_userauth2(int host_key_valid, RSA *own_host_key,
1613 packet_send(); 1624 packet_send();
1614 packet_write_wait(); 1625 packet_write_wait();
1615 } 1626 }
1627 packet_done();
1616 debug("ssh-userauth2 successfull"); 1628 debug("ssh-userauth2 successfull");
1617} 1629}
1618 1630
diff --git a/sshd.c b/sshd.c
index cd5760ecb..cc6bee96a 100644
--- a/sshd.c
+++ b/sshd.c
@@ -14,7 +14,7 @@
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$OpenBSD: sshd.c,v 1.104 2000/04/12 09:39:10 markus Exp $"); 17RCSID("$OpenBSD: sshd.c,v 1.105 2000/04/14 10:30:33 markus Exp $");
18 18
19#include "xmalloc.h" 19#include "xmalloc.h"
20#include "rsa.h" 20#include "rsa.h"
@@ -67,7 +67,7 @@ ServerOptions options;
67/* Name of the server configuration file. */ 67/* Name of the server configuration file. */
68char *config_file_name = SERVER_CONFIG_FILE; 68char *config_file_name = SERVER_CONFIG_FILE;
69 69
70/* 70/*
71 * Flag indicating whether IPv4 or IPv6. This can be set on the command line. 71 * Flag indicating whether IPv4 or IPv6. This can be set on the command line.
72 * Default value is AF_UNSPEC means both IPv4 and IPv6. 72 * Default value is AF_UNSPEC means both IPv4 and IPv6.
73 */ 73 */
@@ -162,7 +162,7 @@ close_listen_socks(void)
162 * the effect is to reread the configuration file (and to regenerate 162 * the effect is to reread the configuration file (and to regenerate
163 * the server key). 163 * the server key).
164 */ 164 */
165void 165void
166sighup_handler(int sig) 166sighup_handler(int sig)
167{ 167{
168 received_sighup = 1; 168 received_sighup = 1;
@@ -173,7 +173,7 @@ sighup_handler(int sig)
173 * Called from the main program after receiving SIGHUP. 173 * Called from the main program after receiving SIGHUP.
174 * Restarts the server. 174 * Restarts the server.
175 */ 175 */
176void 176void
177sighup_restart() 177sighup_restart()
178{ 178{
179 log("Received SIGHUP; restarting."); 179 log("Received SIGHUP; restarting.");
@@ -188,7 +188,7 @@ sighup_restart()
188 * These close the listen socket; not closing it seems to cause "Address 188 * These close the listen socket; not closing it seems to cause "Address
189 * already in use" problems on some machines, which is inconvenient. 189 * already in use" problems on some machines, which is inconvenient.
190 */ 190 */
191void 191void
192sigterm_handler(int sig) 192sigterm_handler(int sig)
193{ 193{
194 log("Received signal %d; terminating.", sig); 194 log("Received signal %d; terminating.", sig);
@@ -200,7 +200,7 @@ sigterm_handler(int sig)
200 * SIGCHLD handler. This is called whenever a child dies. This will then 200 * SIGCHLD handler. This is called whenever a child dies. This will then
201 * reap any zombies left by exited c. 201 * reap any zombies left by exited c.
202 */ 202 */
203void 203void
204main_sigchld_handler(int sig) 204main_sigchld_handler(int sig)
205{ 205{
206 int save_errno = errno; 206 int save_errno = errno;
@@ -216,7 +216,7 @@ main_sigchld_handler(int sig)
216/* 216/*
217 * Signal handler for the alarm after the login grace period has expired. 217 * Signal handler for the alarm after the login grace period has expired.
218 */ 218 */
219void 219void
220grace_alarm_handler(int sig) 220grace_alarm_handler(int sig)
221{ 221{
222 /* Close the connection. */ 222 /* Close the connection. */
@@ -233,7 +233,7 @@ grace_alarm_handler(int sig)
233 * Thus there should be no concurrency control/asynchronous execution 233 * Thus there should be no concurrency control/asynchronous execution
234 * problems. 234 * problems.
235 */ 235 */
236void 236void
237key_regeneration_alarm(int sig) 237key_regeneration_alarm(int sig)
238{ 238{
239 int save_errno = errno; 239 int save_errno = errno;
@@ -266,15 +266,15 @@ key_regeneration_alarm(int sig)
266char * 266char *
267chop(char *s) 267chop(char *s)
268{ 268{
269 char *t = s; 269 char *t = s;
270 while (*t) { 270 while (*t) {
271 if(*t == '\n' || *t == '\r') { 271 if(*t == '\n' || *t == '\r') {
272 *t = '\0'; 272 *t = '\0';
273 return s; 273 return s;
274 } 274 }
275 t++; 275 t++;
276 } 276 }
277 return s; 277 return s;
278 278
279} 279}
280 280
@@ -337,7 +337,7 @@ sshd_exchange_identification(int sock_in, int sock_out)
337 */ 337 */
338 if (sscanf(client_version_string, "SSH-%d.%d-%[^\n]\n", 338 if (sscanf(client_version_string, "SSH-%d.%d-%[^\n]\n",
339 &remote_major, &remote_minor, remote_version) != 3) { 339 &remote_major, &remote_minor, remote_version) != 3) {
340 s = "Protocol mismatch.\n"; 340 s = "Protocol mismatch.\n";
341 (void) atomicio(write, sock_out, s, strlen(s)); 341 (void) atomicio(write, sock_out, s, strlen(s));
342 close(sock_in); 342 close(sock_in);
343 close(sock_out); 343 close(sock_out);
@@ -377,7 +377,7 @@ sshd_exchange_identification(int sock_in, int sock_out)
377 break; 377 break;
378 } 378 }
379 /* FALLTHROUGH */ 379 /* FALLTHROUGH */
380 default: 380 default:
381 mismatch = 1; 381 mismatch = 1;
382 break; 382 break;
383 } 383 }
@@ -719,8 +719,8 @@ main(int ac, char **av)
719 for (i = 0; i < num_listen_socks; i++) 719 for (i = 0; i < num_listen_socks; i++)
720 if (listen_socks[i] > maxfd) 720 if (listen_socks[i] > maxfd)
721 maxfd = listen_socks[i]; 721 maxfd = listen_socks[i];
722 fdsetsz = howmany(maxfd, NFDBITS) * sizeof(fd_mask); 722 fdsetsz = howmany(maxfd, NFDBITS) * sizeof(fd_mask);
723 fdset = (fd_set *)xmalloc(fdsetsz); 723 fdset = (fd_set *)xmalloc(fdsetsz);
724 724
725 /* 725 /*
726 * Stay listening for connections until the system crashes or 726 * Stay listening for connections until the system crashes or
@@ -1018,7 +1018,7 @@ do_ssh1_kex()
1018 /* Get cipher type and check whether we accept this. */ 1018 /* Get cipher type and check whether we accept this. */
1019 cipher_type = packet_get_char(); 1019 cipher_type = packet_get_char();
1020 1020
1021 if (!(cipher_mask() & (1 << cipher_type))) 1021 if (!(cipher_mask() & (1 << cipher_type)))
1022 packet_disconnect("Warning: client selects unsupported cipher."); 1022 packet_disconnect("Warning: client selects unsupported cipher.");
1023 1023
1024 /* Get check bytes from the packet. These must match those we 1024 /* Get check bytes from the packet. These must match those we
@@ -1145,7 +1145,7 @@ do_ssh2_kex()
1145/* KEXINIT */ 1145/* KEXINIT */
1146 1146
1147 if (options.ciphers != NULL) { 1147 if (options.ciphers != NULL) {
1148 myproposal[PROPOSAL_ENC_ALGS_CTOS] = 1148 myproposal[PROPOSAL_ENC_ALGS_CTOS] =
1149 myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers; 1149 myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers;
1150 } 1150 }
1151 1151
@@ -1258,10 +1258,10 @@ do_ssh2_kex()
1258 xfree(client_kexinit); 1258 xfree(client_kexinit);
1259 xfree(server_kexinit); 1259 xfree(server_kexinit);
1260#ifdef DEBUG_KEXDH 1260#ifdef DEBUG_KEXDH
1261 fprintf(stderr, "hash == "); 1261 fprintf(stderr, "hash == ");
1262 for (i = 0; i< 20; i++) 1262 for (i = 0; i< 20; i++)
1263 fprintf(stderr, "%02x", (hash[i])&0xff); 1263 fprintf(stderr, "%02x", (hash[i])&0xff);
1264 fprintf(stderr, "\n"); 1264 fprintf(stderr, "\n");
1265#endif 1265#endif
1266 /* sign H */ 1266 /* sign H */
1267 dsa_sign(server_host_key, &signature, &slen, hash, 20); 1267 dsa_sign(server_host_key, &signature, &slen, hash, 20);
diff --git a/ttymodes.c b/ttymodes.c
index fffc6d5bf..647c66035 100644
--- a/ttymodes.c
+++ b/ttymodes.c
@@ -10,7 +10,7 @@
10 */ 10 */
11 11
12#include "includes.h" 12#include "includes.h"
13RCSID("$Id: ttymodes.c,v 1.3 1999/11/25 00:54:59 damien Exp $"); 13RCSID("$Id: ttymodes.c,v 1.4 2000/04/16 01:18:49 damien Exp $");
14 14
15#include "packet.h" 15#include "packet.h"
16#include "ssh.h" 16#include "ssh.h"
@@ -23,7 +23,7 @@ RCSID("$Id: ttymodes.c,v 1.3 1999/11/25 00:54:59 damien Exp $");
23 * Converts POSIX speed_t to a baud rate. The values of the 23 * Converts POSIX speed_t to a baud rate. The values of the
24 * constants for speed_t are not themselves portable. 24 * constants for speed_t are not themselves portable.
25 */ 25 */
26static int 26static int
27speed_to_baud(speed_t speed) 27speed_to_baud(speed_t speed)
28{ 28{
29 switch (speed) { 29 switch (speed) {
@@ -112,7 +112,7 @@ speed_to_baud(speed_t speed)
112/* 112/*
113 * Converts a numeric baud rate to a POSIX speed_t. 113 * Converts a numeric baud rate to a POSIX speed_t.
114 */ 114 */
115static speed_t 115static speed_t
116baud_to_speed(int baud) 116baud_to_speed(int baud)
117{ 117{
118 switch (baud) { 118 switch (baud) {
@@ -203,7 +203,7 @@ baud_to_speed(int baud)
203 * in a portable manner, and appends the modes to a packet 203 * in a portable manner, and appends the modes to a packet
204 * being constructed. 204 * being constructed.
205 */ 205 */
206void 206void
207tty_make_modes(int fd) 207tty_make_modes(int fd)
208{ 208{
209 struct termios tio; 209 struct termios tio;
@@ -247,7 +247,7 @@ tty_make_modes(int fd)
247 * Decodes terminal modes for the terminal referenced by fd in a portable 247 * Decodes terminal modes for the terminal referenced by fd in a portable
248 * manner from a packet being read. 248 * manner from a packet being read.
249 */ 249 */
250void 250void
251tty_parse_modes(int fd, int *n_bytes_ptr) 251tty_parse_modes(int fd, int *n_bytes_ptr)
252{ 252{
253 struct termios tio; 253 struct termios tio;
diff --git a/ttymodes.h b/ttymodes.h
index 79726aa47..41aad79d6 100644
--- a/ttymodes.h
+++ b/ttymodes.h
@@ -1,18 +1,18 @@
1/* 1/*
2 * 2 *
3 * ttymodes.h 3 * ttymodes.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * SGTTY stuff contributed by Janne Snabb <snabb@niksula.hut.fi> 6 * SGTTY stuff contributed by Janne Snabb <snabb@niksula.hut.fi>
7 * 7 *
8 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 8 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
9 * All rights reserved 9 * All rights reserved
10 * 10 *
11 * Created: Tue Mar 21 15:42:09 1995 ylo 11 * Created: Tue Mar 21 15:42:09 1995 ylo
12 * 12 *
13 */ 13 */
14 14
15/* RCSID("$Id: ttymodes.h,v 1.3 1999/11/25 00:54:59 damien Exp $"); */ 15/* RCSID("$Id: ttymodes.h,v 1.4 2000/04/16 01:18:49 damien Exp $"); */
16 16
17/* The tty mode description is a stream of bytes. The stream consists of 17/* The tty mode description is a stream of bytes. The stream consists of
18 * opcode-arguments pairs. It is terminated by opcode TTY_OP_END (0). 18 * opcode-arguments pairs. It is terminated by opcode TTY_OP_END (0).
diff --git a/uidswap.c b/uidswap.c
index ca9e28eb7..e57be3a3d 100644
--- a/uidswap.c
+++ b/uidswap.c
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9#include "includes.h" 9#include "includes.h"
10RCSID("$Id: uidswap.c,v 1.4 2000/01/20 13:18:16 damien Exp $"); 10RCSID("$Id: uidswap.c,v 1.5 2000/04/16 01:18:49 damien Exp $");
11 11
12#include "ssh.h" 12#include "ssh.h"
13#include "uidswap.h" 13#include "uidswap.h"
@@ -35,7 +35,7 @@ static uid_t saved_euid = 0;
35 * Temporarily changes to the given uid. If the effective user 35 * Temporarily changes to the given uid. If the effective user
36 * id is not root, this does nothing. This call cannot be nested. 36 * id is not root, this does nothing. This call cannot be nested.
37 */ 37 */
38void 38void
39temporarily_use_uid(uid_t uid) 39temporarily_use_uid(uid_t uid)
40{ 40{
41#ifdef SAVED_IDS_WORK_WITH_SETEUID 41#ifdef SAVED_IDS_WORK_WITH_SETEUID
@@ -59,7 +59,7 @@ temporarily_use_uid(uid_t uid)
59/* 59/*
60 * Restores to the original uid. 60 * Restores to the original uid.
61 */ 61 */
62void 62void
63restore_uid() 63restore_uid()
64{ 64{
65#ifdef SAVED_IDS_WORK_WITH_SETEUID 65#ifdef SAVED_IDS_WORK_WITH_SETEUID
@@ -80,7 +80,7 @@ restore_uid()
80 * Permanently sets all uids to the given uid. This cannot be 80 * Permanently sets all uids to the given uid. This cannot be
81 * called while temporarily_use_uid is effective. 81 * called while temporarily_use_uid is effective.
82 */ 82 */
83void 83void
84permanently_set_uid(uid_t uid) 84permanently_set_uid(uid_t uid)
85{ 85{
86 if (setuid(uid) < 0) 86 if (setuid(uid) < 0)
diff --git a/uidswap.h b/uidswap.h
index 4755710de..c08a37004 100644
--- a/uidswap.h
+++ b/uidswap.h
@@ -1,15 +1,15 @@
1/* 1/*
2 * 2 *
3 * uidswap.h 3 * uidswap.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Sat Sep 9 01:43:15 1995 ylo 10 * Created: Sat Sep 9 01:43:15 1995 ylo
11 * Last modified: Sat Sep 9 02:34:04 1995 ylo 11 * Last modified: Sat Sep 9 02:34:04 1995 ylo
12 * 12 *
13 */ 13 */
14 14
15#ifndef UIDSWAP_H 15#ifndef UIDSWAP_H
diff --git a/xmalloc.c b/xmalloc.c
index 0f1c43051..fb29a62e9 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -8,7 +8,7 @@
8 */ 8 */
9 9
10#include "includes.h" 10#include "includes.h"
11RCSID("$Id: xmalloc.c,v 1.2 1999/11/24 13:26:23 damien Exp $"); 11RCSID("$Id: xmalloc.c,v 1.3 2000/04/16 01:18:49 damien Exp $");
12 12
13#include "ssh.h" 13#include "ssh.h"
14 14
@@ -34,7 +34,7 @@ xrealloc(void *ptr, size_t new_size)
34 return new_ptr; 34 return new_ptr;
35} 35}
36 36
37void 37void
38xfree(void *ptr) 38xfree(void *ptr)
39{ 39{
40 if (ptr == NULL) 40 if (ptr == NULL)
diff --git a/xmalloc.h b/xmalloc.h
index 94280b118..a5603522d 100644
--- a/xmalloc.h
+++ b/xmalloc.h
@@ -1,20 +1,20 @@
1/* 1/*
2 * 2 *
3 * xmalloc.h 3 * xmalloc.h
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Mon Mar 20 22:09:17 1995 ylo 10 * Created: Mon Mar 20 22:09:17 1995 ylo
11 * 11 *
12 * Versions of malloc and friends that check their results, and never return 12 * Versions of malloc and friends that check their results, and never return
13 * failure (they call fatal if they encounter an error). 13 * failure (they call fatal if they encounter an error).
14 * 14 *
15 */ 15 */
16 16
17/* RCSID("$Id: xmalloc.h,v 1.2 1999/11/24 13:26:23 damien Exp $"); */ 17/* RCSID("$Id: xmalloc.h,v 1.3 2000/04/16 01:18:49 damien Exp $"); */
18 18
19#ifndef XMALLOC_H 19#ifndef XMALLOC_H
20#define XMALLOC_H 20#define XMALLOC_H