diff options
Diffstat (limited to 'serverloop.c')
-rw-r--r-- | serverloop.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/serverloop.c b/serverloop.c index 9e5fa555e..5f22df3df 100644 --- a/serverloop.c +++ b/serverloop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: serverloop.c,v 1.164 2012/12/07 01:51:35 dtucker Exp $ */ | 1 | /* $OpenBSD: serverloop.c,v 1.168 2013/07/12 00:19:59 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -148,7 +148,7 @@ static void | |||
148 | notify_parent(void) | 148 | notify_parent(void) |
149 | { | 149 | { |
150 | if (notify_pipe[1] != -1) | 150 | if (notify_pipe[1] != -1) |
151 | write(notify_pipe[1], "", 1); | 151 | (void)write(notify_pipe[1], "", 1); |
152 | } | 152 | } |
153 | static void | 153 | static void |
154 | notify_prepare(fd_set *readset) | 154 | notify_prepare(fd_set *readset) |
@@ -277,7 +277,7 @@ client_alive_check(void) | |||
277 | */ | 277 | */ |
278 | static void | 278 | static void |
279 | wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp, | 279 | wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp, |
280 | u_int *nallocp, u_int max_time_milliseconds) | 280 | u_int *nallocp, u_int64_t max_time_milliseconds) |
281 | { | 281 | { |
282 | struct timeval tv, *tvp; | 282 | struct timeval tv, *tvp; |
283 | int ret; | 283 | int ret; |
@@ -563,7 +563,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg) | |||
563 | int wait_status; /* Status returned by wait(). */ | 563 | int wait_status; /* Status returned by wait(). */ |
564 | pid_t wait_pid; /* pid returned by wait(). */ | 564 | pid_t wait_pid; /* pid returned by wait(). */ |
565 | int waiting_termination = 0; /* Have displayed waiting close message. */ | 565 | int waiting_termination = 0; /* Have displayed waiting close message. */ |
566 | u_int max_time_milliseconds; | 566 | u_int64_t max_time_milliseconds; |
567 | u_int previous_stdout_buffer_bytes; | 567 | u_int previous_stdout_buffer_bytes; |
568 | u_int stdout_buffer_bytes; | 568 | u_int stdout_buffer_bytes; |
569 | int type; | 569 | int type; |
@@ -694,7 +694,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg) | |||
694 | /* Display list of open channels. */ | 694 | /* Display list of open channels. */ |
695 | cp = channel_open_message(); | 695 | cp = channel_open_message(); |
696 | buffer_append(&stderr_buffer, cp, strlen(cp)); | 696 | buffer_append(&stderr_buffer, cp, strlen(cp)); |
697 | xfree(cp); | 697 | free(cp); |
698 | } | 698 | } |
699 | } | 699 | } |
700 | max_fd = MAX(connection_in, connection_out); | 700 | max_fd = MAX(connection_in, connection_out); |
@@ -722,10 +722,8 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg) | |||
722 | /* Process output to the client and to program stdin. */ | 722 | /* Process output to the client and to program stdin. */ |
723 | process_output(writeset); | 723 | process_output(writeset); |
724 | } | 724 | } |
725 | if (readset) | 725 | free(readset); |
726 | xfree(readset); | 726 | free(writeset); |
727 | if (writeset) | ||
728 | xfree(writeset); | ||
729 | 727 | ||
730 | /* Cleanup and termination code. */ | 728 | /* Cleanup and termination code. */ |
731 | 729 | ||
@@ -825,7 +823,9 @@ void | |||
825 | server_loop2(Authctxt *authctxt) | 823 | server_loop2(Authctxt *authctxt) |
826 | { | 824 | { |
827 | fd_set *readset = NULL, *writeset = NULL; | 825 | fd_set *readset = NULL, *writeset = NULL; |
828 | int rekeying = 0, max_fd, nalloc = 0; | 826 | int rekeying = 0, max_fd; |
827 | u_int nalloc = 0; | ||
828 | u_int64_t rekey_timeout_ms = 0; | ||
829 | 829 | ||
830 | debug("Entering interactive session for SSH2."); | 830 | debug("Entering interactive session for SSH2."); |
831 | 831 | ||
@@ -854,8 +854,13 @@ server_loop2(Authctxt *authctxt) | |||
854 | 854 | ||
855 | if (!rekeying && packet_not_very_much_data_to_write()) | 855 | if (!rekeying && packet_not_very_much_data_to_write()) |
856 | channel_output_poll(); | 856 | channel_output_poll(); |
857 | if (options.rekey_interval > 0 && compat20 && !rekeying) | ||
858 | rekey_timeout_ms = packet_get_rekey_timeout() * 1000; | ||
859 | else | ||
860 | rekey_timeout_ms = 0; | ||
861 | |||
857 | wait_until_can_do_something(&readset, &writeset, &max_fd, | 862 | wait_until_can_do_something(&readset, &writeset, &max_fd, |
858 | &nalloc, 0); | 863 | &nalloc, rekey_timeout_ms); |
859 | 864 | ||
860 | if (received_sigterm) { | 865 | if (received_sigterm) { |
861 | logit("Exiting on signal %d", (int)received_sigterm); | 866 | logit("Exiting on signal %d", (int)received_sigterm); |
@@ -879,10 +884,8 @@ server_loop2(Authctxt *authctxt) | |||
879 | } | 884 | } |
880 | collect_children(); | 885 | collect_children(); |
881 | 886 | ||
882 | if (readset) | 887 | free(readset); |
883 | xfree(readset); | 888 | free(writeset); |
884 | if (writeset) | ||
885 | xfree(writeset); | ||
886 | 889 | ||
887 | /* free all channels, no more reads and writes */ | 890 | /* free all channels, no more reads and writes */ |
888 | channel_free_all(); | 891 | channel_free_all(); |
@@ -917,7 +920,7 @@ server_input_stdin_data(int type, u_int32_t seq, void *ctxt) | |||
917 | packet_check_eom(); | 920 | packet_check_eom(); |
918 | buffer_append(&stdin_buffer, data, data_len); | 921 | buffer_append(&stdin_buffer, data, data_len); |
919 | memset(data, 0, data_len); | 922 | memset(data, 0, data_len); |
920 | xfree(data); | 923 | free(data); |
921 | } | 924 | } |
922 | 925 | ||
923 | static void | 926 | static void |
@@ -974,8 +977,8 @@ server_request_direct_tcpip(void) | |||
974 | originator, originator_port, target, target_port); | 977 | originator, originator_port, target, target_port); |
975 | } | 978 | } |
976 | 979 | ||
977 | xfree(originator); | 980 | free(originator); |
978 | xfree(target); | 981 | free(target); |
979 | 982 | ||
980 | return c; | 983 | return c; |
981 | } | 984 | } |
@@ -1104,7 +1107,7 @@ server_input_channel_open(int type, u_int32_t seq, void *ctxt) | |||
1104 | } | 1107 | } |
1105 | packet_send(); | 1108 | packet_send(); |
1106 | } | 1109 | } |
1107 | xfree(ctype); | 1110 | free(ctype); |
1108 | } | 1111 | } |
1109 | 1112 | ||
1110 | static void | 1113 | static void |
@@ -1149,7 +1152,7 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt) | |||
1149 | listen_address, listen_port, | 1152 | listen_address, listen_port, |
1150 | &allocated_listen_port, options.gateway_ports); | 1153 | &allocated_listen_port, options.gateway_ports); |
1151 | } | 1154 | } |
1152 | xfree(listen_address); | 1155 | free(listen_address); |
1153 | } else if (strcmp(rtype, "cancel-tcpip-forward") == 0) { | 1156 | } else if (strcmp(rtype, "cancel-tcpip-forward") == 0) { |
1154 | char *cancel_address; | 1157 | char *cancel_address; |
1155 | u_short cancel_port; | 1158 | u_short cancel_port; |
@@ -1161,7 +1164,7 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt) | |||
1161 | 1164 | ||
1162 | success = channel_cancel_rport_listener(cancel_address, | 1165 | success = channel_cancel_rport_listener(cancel_address, |
1163 | cancel_port); | 1166 | cancel_port); |
1164 | xfree(cancel_address); | 1167 | free(cancel_address); |
1165 | } else if (strcmp(rtype, "no-more-sessions@openssh.com") == 0) { | 1168 | } else if (strcmp(rtype, "no-more-sessions@openssh.com") == 0) { |
1166 | no_more_sessions = 1; | 1169 | no_more_sessions = 1; |
1167 | success = 1; | 1170 | success = 1; |
@@ -1174,7 +1177,7 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt) | |||
1174 | packet_send(); | 1177 | packet_send(); |
1175 | packet_write_wait(); | 1178 | packet_write_wait(); |
1176 | } | 1179 | } |
1177 | xfree(rtype); | 1180 | free(rtype); |
1178 | } | 1181 | } |
1179 | 1182 | ||
1180 | static void | 1183 | static void |
@@ -1206,7 +1209,7 @@ server_input_channel_req(int type, u_int32_t seq, void *ctxt) | |||
1206 | packet_put_int(c->remote_id); | 1209 | packet_put_int(c->remote_id); |
1207 | packet_send(); | 1210 | packet_send(); |
1208 | } | 1211 | } |
1209 | xfree(rtype); | 1212 | free(rtype); |
1210 | } | 1213 | } |
1211 | 1214 | ||
1212 | static void | 1215 | static void |