summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/clientloop.c b/clientloop.c
index 547ccabfe..cdd32dbbe 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.51 2001/02/13 21:51:09 markus Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.52 2001/02/28 08:45:39 markus Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -279,10 +279,8 @@ client_check_initial_eof_on_stdin(void)
279 */ 279 */
280 if ((u_char) buf[0] == escape_char) 280 if ((u_char) buf[0] == escape_char)
281 escape_pending = 1; 281 escape_pending = 1;
282 else { 282 else
283 buffer_append(&stdin_buffer, buf, 1); 283 buffer_append(&stdin_buffer, buf, 1);
284 stdin_bytes += 1;
285 }
286 } 284 }
287 leave_non_blocking(); 285 leave_non_blocking();
288 } 286 }
@@ -310,6 +308,7 @@ client_make_packets_from_stdin_data(void)
310 packet_put_string(buffer_ptr(&stdin_buffer), len); 308 packet_put_string(buffer_ptr(&stdin_buffer), len);
311 packet_send(); 309 packet_send();
312 buffer_consume(&stdin_buffer, len); 310 buffer_consume(&stdin_buffer, len);
311 stdin_bytes += len;
313 /* If we have a pending EOF, send it now. */ 312 /* If we have a pending EOF, send it now. */
314 if (stdin_eof && buffer_len(&stdin_buffer) == 0) { 313 if (stdin_eof && buffer_len(&stdin_buffer) == 0) {
315 packet_start(SSH_CMSG_EOF); 314 packet_start(SSH_CMSG_EOF);
@@ -420,7 +419,6 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
420 /* Note: we might still have data in the buffers. */ 419 /* Note: we might still have data in the buffers. */
421 snprintf(buf, sizeof buf, "select: %s\r\n", strerror(errno)); 420 snprintf(buf, sizeof buf, "select: %s\r\n", strerror(errno));
422 buffer_append(&stderr_buffer, buf, strlen(buf)); 421 buffer_append(&stderr_buffer, buf, strlen(buf));
423 stderr_bytes += strlen(buf);
424 quit_pending = 1; 422 quit_pending = 1;
425 } 423 }
426} 424}
@@ -486,7 +484,6 @@ client_process_net_input(fd_set * readset)
486 snprintf(buf, sizeof buf, "Connection to %.300s closed by remote host.\r\n", 484 snprintf(buf, sizeof buf, "Connection to %.300s closed by remote host.\r\n",
487 host); 485 host);
488 buffer_append(&stderr_buffer, buf, strlen(buf)); 486 buffer_append(&stderr_buffer, buf, strlen(buf));
489 stderr_bytes += strlen(buf);
490 quit_pending = 1; 487 quit_pending = 1;
491 return; 488 return;
492 } 489 }
@@ -502,7 +499,6 @@ client_process_net_input(fd_set * readset)
502 snprintf(buf, sizeof buf, "Read from remote host %.300s: %.100s\r\n", 499 snprintf(buf, sizeof buf, "Read from remote host %.300s: %.100s\r\n",
503 host, strerror(errno)); 500 host, strerror(errno));
504 buffer_append(&stderr_buffer, buf, strlen(buf)); 501 buffer_append(&stderr_buffer, buf, strlen(buf));
505 stderr_bytes += strlen(buf);
506 quit_pending = 1; 502 quit_pending = 1;
507 return; 503 return;
508 } 504 }
@@ -536,7 +532,6 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
536 /* Terminate the connection. */ 532 /* Terminate the connection. */
537 snprintf(string, sizeof string, "%c.\r\n", escape_char); 533 snprintf(string, sizeof string, "%c.\r\n", escape_char);
538 buffer_append(berr, string, strlen(string)); 534 buffer_append(berr, string, strlen(string));
539 /*stderr_bytes += strlen(string); XXX*/
540 535
541 quit_pending = 1; 536 quit_pending = 1;
542 return -1; 537 return -1;
@@ -546,7 +541,6 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
546 /* Print a message to that effect to the user. */ 541 /* Print a message to that effect to the user. */
547 snprintf(string, sizeof string, "%c^Z [suspend ssh]\r\n", escape_char); 542 snprintf(string, sizeof string, "%c^Z [suspend ssh]\r\n", escape_char);
548 buffer_append(berr, string, strlen(string)); 543 buffer_append(berr, string, strlen(string));
549 /*stderr_bytes += strlen(string); XXX*/
550 544
551 /* Restore terminal modes and suspend. */ 545 /* Restore terminal modes and suspend. */
552 client_suspend_self(bin, bout, berr); 546 client_suspend_self(bin, bout, berr);
@@ -656,7 +650,6 @@ Supported escape sequences:\r\n\
656void 650void
657client_process_input(fd_set * readset) 651client_process_input(fd_set * readset)
658{ 652{
659 int ret;
660 int len; 653 int len;
661 char buf[8192]; 654 char buf[8192];
662 655
@@ -673,7 +666,6 @@ client_process_input(fd_set * readset)
673 if (len < 0) { 666 if (len < 0) {
674 snprintf(buf, sizeof buf, "read: %.100s\r\n", strerror(errno)); 667 snprintf(buf, sizeof buf, "read: %.100s\r\n", strerror(errno));
675 buffer_append(&stderr_buffer, buf, strlen(buf)); 668 buffer_append(&stderr_buffer, buf, strlen(buf));
676 stderr_bytes += strlen(buf);
677 } 669 }
678 /* Mark that we have seen EOF. */ 670 /* Mark that we have seen EOF. */
679 stdin_eof = 1; 671 stdin_eof = 1;
@@ -694,16 +686,14 @@ client_process_input(fd_set * readset)
694 * Just append the data to buffer. 686 * Just append the data to buffer.
695 */ 687 */
696 buffer_append(&stdin_buffer, buf, len); 688 buffer_append(&stdin_buffer, buf, len);
697 stdin_bytes += len;
698 } else { 689 } else {
699 /* 690 /*
700 * Normal, successful read. But we have an escape character 691 * Normal, successful read. But we have an escape character
701 * and have to process the characters one by one. 692 * and have to process the characters one by one.
702 */ 693 */
703 ret = process_escapes(&stdin_buffer, &stdout_buffer, &stderr_buffer, buf, len); 694 if (process_escapes(&stdin_buffer, &stdout_buffer,
704 if (ret == -1) 695 &stderr_buffer, buf, len) == -1)
705 return; 696 return;
706 stdout_bytes += ret;
707 } 697 }
708 } 698 }
709} 699}
@@ -729,13 +719,13 @@ client_process_output(fd_set * writeset)
729 */ 719 */
730 snprintf(buf, sizeof buf, "write stdout: %.50s\r\n", strerror(errno)); 720 snprintf(buf, sizeof buf, "write stdout: %.50s\r\n", strerror(errno));
731 buffer_append(&stderr_buffer, buf, strlen(buf)); 721 buffer_append(&stderr_buffer, buf, strlen(buf));
732 stderr_bytes += strlen(buf);
733 quit_pending = 1; 722 quit_pending = 1;
734 return; 723 return;
735 } 724 }
736 } 725 }
737 /* Consume printed data from the buffer. */ 726 /* Consume printed data from the buffer. */
738 buffer_consume(&stdout_buffer, len); 727 buffer_consume(&stdout_buffer, len);
728 stdout_bytes += len;
739 } 729 }
740 /* Write buffered output to stderr. */ 730 /* Write buffered output to stderr. */
741 if (FD_ISSET(fileno(stderr), writeset)) { 731 if (FD_ISSET(fileno(stderr), writeset)) {
@@ -753,6 +743,7 @@ client_process_output(fd_set * writeset)
753 } 743 }
754 /* Consume printed characters from the buffer. */ 744 /* Consume printed characters from the buffer. */
755 buffer_consume(&stderr_buffer, len); 745 buffer_consume(&stderr_buffer, len);
746 stderr_bytes += len;
756 } 747 }
757} 748}
758 749
@@ -939,7 +930,6 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
939 if (have_pty && options.log_level != SYSLOG_LEVEL_QUIET) { 930 if (have_pty && options.log_level != SYSLOG_LEVEL_QUIET) {
940 snprintf(buf, sizeof buf, "Connection to %.64s closed.\r\n", host); 931 snprintf(buf, sizeof buf, "Connection to %.64s closed.\r\n", host);
941 buffer_append(&stderr_buffer, buf, strlen(buf)); 932 buffer_append(&stderr_buffer, buf, strlen(buf));
942 stderr_bytes += strlen(buf);
943 } 933 }
944 /* Output any buffered data for stdout. */ 934 /* Output any buffered data for stdout. */
945 while (buffer_len(&stdout_buffer) > 0) { 935 while (buffer_len(&stdout_buffer) > 0) {
@@ -950,6 +940,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
950 break; 940 break;
951 } 941 }
952 buffer_consume(&stdout_buffer, len); 942 buffer_consume(&stdout_buffer, len);
943 stdout_bytes += len;
953 } 944 }
954 945
955 /* Output any buffered data for stderr. */ 946 /* Output any buffered data for stderr. */
@@ -961,6 +952,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
961 break; 952 break;
962 } 953 }
963 buffer_consume(&stderr_buffer, len); 954 buffer_consume(&stderr_buffer, len);
955 stderr_bytes += len;
964 } 956 }
965 957
966 if (have_pty) 958 if (have_pty)
@@ -995,7 +987,6 @@ client_input_stdout_data(int type, int plen, void *ctxt)
995 char *data = packet_get_string(&data_len); 987 char *data = packet_get_string(&data_len);
996 packet_integrity_check(plen, 4 + data_len, type); 988 packet_integrity_check(plen, 4 + data_len, type);
997 buffer_append(&stdout_buffer, data, data_len); 989 buffer_append(&stdout_buffer, data, data_len);
998 stdout_bytes += data_len;
999 memset(data, 0, data_len); 990 memset(data, 0, data_len);
1000 xfree(data); 991 xfree(data);
1001} 992}
@@ -1006,7 +997,6 @@ client_input_stderr_data(int type, int plen, void *ctxt)
1006 char *data = packet_get_string(&data_len); 997 char *data = packet_get_string(&data_len);
1007 packet_integrity_check(plen, 4 + data_len, type); 998 packet_integrity_check(plen, 4 + data_len, type);
1008 buffer_append(&stderr_buffer, data, data_len); 999 buffer_append(&stderr_buffer, data, data_len);
1009 stdout_bytes += data_len;
1010 memset(data, 0, data_len); 1000 memset(data, 0, data_len);
1011 xfree(data); 1001 xfree(data);
1012} 1002}