| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssh/src/packet.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||
| 16 | - | |||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||
| 27 | struct packet_state { | - | ||||||||||||||||||||||||
| 28 | u_int32_t seqnr; | - | ||||||||||||||||||||||||
| 29 | u_int32_t packets; | - | ||||||||||||||||||||||||
| 30 | u_int64_t blocks; | - | ||||||||||||||||||||||||
| 31 | u_int64_t bytes; | - | ||||||||||||||||||||||||
| 32 | }; | - | ||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||
| 34 | struct packet { | - | ||||||||||||||||||||||||
| 35 | struct { struct packet *tqe_next; struct packet **tqe_prev; } next; | - | ||||||||||||||||||||||||
| 36 | u_char type; | - | ||||||||||||||||||||||||
| 37 | struct sshbuf *payload; | - | ||||||||||||||||||||||||
| 38 | }; | - | ||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||
| 40 | struct session_state { | - | ||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | - | |||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||
| 47 | int connection_in; | - | ||||||||||||||||||||||||
| 48 | int connection_out; | - | ||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | u_int remote_protocol_flags; | - | ||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||
| 54 | struct sshcipher_ctx *receive_context; | - | ||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||
| 57 | struct sshcipher_ctx *send_context; | - | ||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||
| 60 | struct sshbuf *input; | - | ||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||
| 62 | - | |||||||||||||||||||||||||
| 63 | struct sshbuf *output; | - | ||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||
| 66 | struct sshbuf *outgoing_packet; | - | ||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | struct sshbuf *incoming_packet; | - | ||||||||||||||||||||||||
| 70 | - | |||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||
| 72 | struct sshbuf *compression_buffer; | - | ||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | z_stream compression_in_stream; | - | ||||||||||||||||||||||||
| 76 | z_stream compression_out_stream; | - | ||||||||||||||||||||||||
| 77 | int compression_in_started; | - | ||||||||||||||||||||||||
| 78 | int compression_out_started; | - | ||||||||||||||||||||||||
| 79 | int compression_in_failures; | - | ||||||||||||||||||||||||
| 80 | int compression_out_failures; | - | ||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||
| 83 | u_int max_packet_size; | - | ||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||
| 86 | int initialized; | - | ||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | int interactive_mode; | - | ||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | int server_side; | - | ||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||
| 95 | int after_authentication; | - | ||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||
| 97 | int keep_alive_timeouts; | - | ||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||
| 100 | int packet_timeout_ms; | - | ||||||||||||||||||||||||
| 101 | - | |||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | struct newkeys *newkeys[MODE_MAX]; | - | ||||||||||||||||||||||||
| 104 | struct packet_state p_read, p_send; | - | ||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | u_int64_t max_blocks_in, max_blocks_out, rekey_limit; | - | ||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | u_int32_t rekey_interval; | - | ||||||||||||||||||||||||
| 111 | time_t rekey_time; | - | ||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||
| 114 | u_char extra_pad; | - | ||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | u_int packet_discard; | - | ||||||||||||||||||||||||
| 118 | size_t packet_discard_mac_already; | - | ||||||||||||||||||||||||
| 119 | struct sshmac *packet_discard_mac; | - | ||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||
| 122 | u_int packlen; | - | ||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||
| 125 | int rekeying; | - | ||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | int mux; | - | ||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 | int set_interactive_called; | - | ||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | int set_maxsize_called; | - | ||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | - | |||||||||||||||||||||||||
| 137 | int cipher_warning_done; | - | ||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | ssh_packet_hook_fn *hook_in; | - | ||||||||||||||||||||||||
| 141 | void *hook_in_ctx; | - | ||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | struct { struct packet *tqh_first; struct packet **tqh_last; } outgoing; | - | ||||||||||||||||||||||||
| 144 | }; | - | ||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | struct ssh * | - | ||||||||||||||||||||||||
| 147 | ssh_alloc_session_state(void) | - | ||||||||||||||||||||||||
| 148 | { | - | ||||||||||||||||||||||||
| 149 | struct ssh *ssh = | - | ||||||||||||||||||||||||
| 150 | ((void *)0) | - | ||||||||||||||||||||||||
| 151 | ; | - | ||||||||||||||||||||||||
| 152 | struct session_state *state = | - | ||||||||||||||||||||||||
| 153 | ((void *)0) | - | ||||||||||||||||||||||||
| 154 | ; | - | ||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||
| 156 | if ((
| 0-96 | ||||||||||||||||||||||||
| 157 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 158 | || | - | ||||||||||||||||||||||||
| 159 | (
| 0-96 | ||||||||||||||||||||||||
| 160 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 161 | || | - | ||||||||||||||||||||||||
| 162 | (
| 0-96 | ||||||||||||||||||||||||
| 163 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 164 | || | - | ||||||||||||||||||||||||
| 165 | (
| 0-96 | ||||||||||||||||||||||||
| 166 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 167 | || | - | ||||||||||||||||||||||||
| 168 | (
| 0-96 | ||||||||||||||||||||||||
| 169 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 170 | || | - | ||||||||||||||||||||||||
| 171 | (
| 0-96 | ||||||||||||||||||||||||
| 172 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 173 | ) | - | ||||||||||||||||||||||||
| 174 | goto never executed: fail;goto fail;never executed: goto fail; | 0 | ||||||||||||||||||||||||
| 175 | do { (&state->outgoing)->tqh_first = | - | ||||||||||||||||||||||||
| 176 | ((void *)0) | - | ||||||||||||||||||||||||
| 177 | ; (&state->outgoing)->tqh_last = &(&state->outgoing)->tqh_first; } while (0); | - | ||||||||||||||||||||||||
| 178 | do { (&ssh->private_keys)->tqh_first = | - | ||||||||||||||||||||||||
| 179 | ((void *)0) | - | ||||||||||||||||||||||||
| 180 | ; (&ssh->private_keys)->tqh_last = &(&ssh->private_keys)->tqh_first; } while (0); | - | ||||||||||||||||||||||||
| 181 | do { (&ssh->public_keys)->tqh_first = | - | ||||||||||||||||||||||||
| 182 | ((void *)0) | - | ||||||||||||||||||||||||
| 183 | ; (&ssh->public_keys)->tqh_last = &(&ssh->public_keys)->tqh_first; } while (0); | - | ||||||||||||||||||||||||
| 184 | state->connection_in = -1; | - | ||||||||||||||||||||||||
| 185 | state->connection_out = -1; | - | ||||||||||||||||||||||||
| 186 | state->max_packet_size = 32768; | - | ||||||||||||||||||||||||
| 187 | state->packet_timeout_ms = -1; | - | ||||||||||||||||||||||||
| 188 | state->p_send.packets = state->p_read.packets = 0; | - | ||||||||||||||||||||||||
| 189 | state->initialized = 1; | - | ||||||||||||||||||||||||
| 190 | - | |||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | - | |||||||||||||||||||||||||
| 194 | state->rekeying = 1; | - | ||||||||||||||||||||||||
| 195 | ssh->state = state; | - | ||||||||||||||||||||||||
| 196 | return executed 96 times by 1 test: ssh;return ssh;Executed by:
executed 96 times by 1 test: return ssh;Executed by:
| 96 | ||||||||||||||||||||||||
| 197 | fail: | - | ||||||||||||||||||||||||
| 198 | if (state
| 0 | ||||||||||||||||||||||||
| 199 | sshbuf_free(state->input); | - | ||||||||||||||||||||||||
| 200 | sshbuf_free(state->output); | - | ||||||||||||||||||||||||
| 201 | sshbuf_free(state->incoming_packet); | - | ||||||||||||||||||||||||
| 202 | sshbuf_free(state->outgoing_packet); | - | ||||||||||||||||||||||||
| 203 | free(state); | - | ||||||||||||||||||||||||
| 204 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 205 | free(ssh); | - | ||||||||||||||||||||||||
| 206 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 207 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 208 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 209 | } | - | ||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | void | - | ||||||||||||||||||||||||
| 212 | ssh_packet_set_input_hook(struct ssh *ssh, ssh_packet_hook_fn *hook, void *ctx) | - | ||||||||||||||||||||||||
| 213 | { | - | ||||||||||||||||||||||||
| 214 | ssh->state->hook_in = hook; | - | ||||||||||||||||||||||||
| 215 | ssh->state->hook_in_ctx = ctx; | - | ||||||||||||||||||||||||
| 216 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||
| 219 | int | - | ||||||||||||||||||||||||
| 220 | ssh_packet_is_rekeying(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 221 | { | - | ||||||||||||||||||||||||
| 222 | return executed 208 times by 1 test: ssh->state->rekeyingreturn ssh->state->rekeying || (ssh->kex != ((void *)0) && ssh->kex->done == 0);Executed by:
executed 208 times by 1 test: return ssh->state->rekeying || (ssh->kex != ((void *)0) && ssh->kex->done == 0);Executed by:
| 96-208 | ||||||||||||||||||||||||
| 223 | (ssh->kex !=
executed 208 times by 1 test: return ssh->state->rekeying || (ssh->kex != ((void *)0) && ssh->kex->done == 0);Executed by:
| 0-208 | ||||||||||||||||||||||||
| 224 | ((void *)0)
executed 208 times by 1 test: return ssh->state->rekeying || (ssh->kex != ((void *)0) && ssh->kex->done == 0);Executed by:
| 0-208 | ||||||||||||||||||||||||
| 225 | && ssh->kex->done == 0
executed 208 times by 1 test: return ssh->state->rekeying || (ssh->kex != ((void *)0) && ssh->kex->done == 0);Executed by:
| 32-208 | ||||||||||||||||||||||||
| 226 | } | - | ||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||
| 230 | - | |||||||||||||||||||||||||
| 231 | struct ssh * | - | ||||||||||||||||||||||||
| 232 | ssh_packet_set_connection(struct ssh *ssh, int fd_in, int fd_out) | - | ||||||||||||||||||||||||
| 233 | { | - | ||||||||||||||||||||||||
| 234 | struct session_state *state; | - | ||||||||||||||||||||||||
| 235 | const struct sshcipher *none = cipher_by_name("none"); | - | ||||||||||||||||||||||||
| 236 | int r; | - | ||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 | if (none ==
| 0-96 | ||||||||||||||||||||||||
| 239 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 240 | ) { | - | ||||||||||||||||||||||||
| 241 | error("%s: cannot load cipher 'none'", __func__); | - | ||||||||||||||||||||||||
| 242 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 243 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 244 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 245 | } | - | ||||||||||||||||||||||||
| 246 | if (ssh ==
| 0-96 | ||||||||||||||||||||||||
| 247 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 248 | ) | - | ||||||||||||||||||||||||
| 249 | ssh = ssh_alloc_session_state(); executed 96 times by 1 test: ssh = ssh_alloc_session_state();Executed by:
| 96 | ||||||||||||||||||||||||
| 250 | if (ssh ==
| 0-96 | ||||||||||||||||||||||||
| 251 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 252 | ) { | - | ||||||||||||||||||||||||
| 253 | error("%s: cound not allocate state", __func__); | - | ||||||||||||||||||||||||
| 254 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 255 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 256 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 257 | } | - | ||||||||||||||||||||||||
| 258 | state = ssh->state; | - | ||||||||||||||||||||||||
| 259 | state->connection_in = fd_in; | - | ||||||||||||||||||||||||
| 260 | state->connection_out = fd_out; | - | ||||||||||||||||||||||||
| 261 | if ((
| 0-96 | ||||||||||||||||||||||||
| 262 | (const u_char *)"", 0,
| 0-96 | ||||||||||||||||||||||||
| 263 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 264 | , 0, 1)) != 0
| 0-96 | ||||||||||||||||||||||||
| 265 | (
| 0-96 | ||||||||||||||||||||||||
| 266 | (const u_char *)"", 0,
| 0-96 | ||||||||||||||||||||||||
| 267 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 268 | , 0, 0)) != 0
| 0-96 | ||||||||||||||||||||||||
| 269 | error("%s: cipher_init failed: %s", __func__, ssh_err(r)); | - | ||||||||||||||||||||||||
| 270 | free(ssh); | - | ||||||||||||||||||||||||
| 271 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 272 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 273 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 274 | } | - | ||||||||||||||||||||||||
| 275 | state->newkeys[MODE_IN] = state->newkeys[MODE_OUT] = | - | ||||||||||||||||||||||||
| 276 | ((void *)0) | - | ||||||||||||||||||||||||
| 277 | ; | - | ||||||||||||||||||||||||
| 278 | - | |||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||
| 280 | - | |||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||
| 282 | (void)ssh_remote_ipaddr(ssh); | - | ||||||||||||||||||||||||
| 283 | return executed 96 times by 1 test: ssh;return ssh;Executed by:
executed 96 times by 1 test: return ssh;Executed by:
| 96 | ||||||||||||||||||||||||
| 284 | } | - | ||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||
| 286 | void | - | ||||||||||||||||||||||||
| 287 | ssh_packet_set_timeout(struct ssh *ssh, int timeout, int count) | - | ||||||||||||||||||||||||
| 288 | { | - | ||||||||||||||||||||||||
| 289 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | if (timeout <= 0
| 0 | ||||||||||||||||||||||||
| 292 | state->packet_timeout_ms = -1; | - | ||||||||||||||||||||||||
| 293 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 294 | } | - | ||||||||||||||||||||||||
| 295 | if ((
| 0 | ||||||||||||||||||||||||
| 296 | state->packet_timeout_ms = 0x7fffffff; never executed: state->packet_timeout_ms = 0x7fffffff; | 0 | ||||||||||||||||||||||||
| 297 | else | - | ||||||||||||||||||||||||
| 298 | state->packet_timeout_ms = timeout * count * 1000; never executed: state->packet_timeout_ms = timeout * count * 1000; | 0 | ||||||||||||||||||||||||
| 299 | } | - | ||||||||||||||||||||||||
| 300 | - | |||||||||||||||||||||||||
| 301 | void | - | ||||||||||||||||||||||||
| 302 | ssh_packet_set_mux(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 303 | { | - | ||||||||||||||||||||||||
| 304 | ssh->state->mux = 1; | - | ||||||||||||||||||||||||
| 305 | ssh->state->rekeying = 0; | - | ||||||||||||||||||||||||
| 306 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 307 | - | |||||||||||||||||||||||||
| 308 | int | - | ||||||||||||||||||||||||
| 309 | ssh_packet_get_mux(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 310 | { | - | ||||||||||||||||||||||||
| 311 | return never executed: ssh->state->mux;return ssh->state->mux;never executed: return ssh->state->mux; | 0 | ||||||||||||||||||||||||
| 312 | } | - | ||||||||||||||||||||||||
| 313 | - | |||||||||||||||||||||||||
| 314 | int | - | ||||||||||||||||||||||||
| 315 | ssh_packet_set_log_preamble(struct ssh *ssh, const char *fmt, ...) | - | ||||||||||||||||||||||||
| 316 | { | - | ||||||||||||||||||||||||
| 317 | va_list args; | - | ||||||||||||||||||||||||
| 318 | int r; | - | ||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||
| 320 | free(ssh->log_preamble); | - | ||||||||||||||||||||||||
| 321 | if (fmt ==
| 0 | ||||||||||||||||||||||||
| 322 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 323 | ) | - | ||||||||||||||||||||||||
| 324 | ssh->log_preamble = never executed: ssh->log_preamble = ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 325 | ((void *)0) never executed: ssh->log_preamble = ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 326 | ; never executed: ssh->log_preamble = ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 327 | else { | - | ||||||||||||||||||||||||
| 328 | - | |||||||||||||||||||||||||
| 329 | __builtin_va_start( | - | ||||||||||||||||||||||||
| 330 | args | - | ||||||||||||||||||||||||
| 331 | , | - | ||||||||||||||||||||||||
| 332 | fmt | - | ||||||||||||||||||||||||
| 333 | ) | - | ||||||||||||||||||||||||
| 334 | ; | - | ||||||||||||||||||||||||
| 335 | r = vasprintf(&ssh->log_preamble, fmt, args); | - | ||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||
| 337 | __builtin_va_end( | - | ||||||||||||||||||||||||
| 338 | args | - | ||||||||||||||||||||||||
| 339 | ) | - | ||||||||||||||||||||||||
| 340 | ; | - | ||||||||||||||||||||||||
| 341 | if (r < 0
| 0 | ||||||||||||||||||||||||
| 342 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 343 | ) | - | ||||||||||||||||||||||||
| 344 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||
| 345 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 346 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 347 | } | - | ||||||||||||||||||||||||
| 348 | - | |||||||||||||||||||||||||
| 349 | int | - | ||||||||||||||||||||||||
| 350 | ssh_packet_stop_discard(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 351 | { | - | ||||||||||||||||||||||||
| 352 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 353 | int r; | - | ||||||||||||||||||||||||
| 354 | - | |||||||||||||||||||||||||
| 355 | if (state->packet_discard_mac
| 0 | ||||||||||||||||||||||||
| 356 | char buf[1024]; | - | ||||||||||||||||||||||||
| 357 | size_t dlen = (256 * 1024); | - | ||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | if (dlen > state->packet_discard_mac_already
| 0 | ||||||||||||||||||||||||
| 360 | dlen -= state->packet_discard_mac_already; never executed: dlen -= state->packet_discard_mac_already; | 0 | ||||||||||||||||||||||||
| 361 | memset(buf, 'a', sizeof(buf)); | - | ||||||||||||||||||||||||
| 362 | while (sshbuf_len(state->incoming_packet) < dlen
| 0 | ||||||||||||||||||||||||
| 363 | if ((
| 0 | ||||||||||||||||||||||||
| 364 | sizeof(buf))) != 0
| 0 | ||||||||||||||||||||||||
| 365 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 366 | (void) mac_compute(state->packet_discard_mac, | - | ||||||||||||||||||||||||
| 367 | state->p_read.seqnr, | - | ||||||||||||||||||||||||
| 368 | sshbuf_ptr(state->incoming_packet), dlen, | - | ||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||
| 370 | ((void *)0) | - | ||||||||||||||||||||||||
| 371 | , 0); | - | ||||||||||||||||||||||||
| 372 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 373 | logit("Finished discarding for %.200s port %d", | - | ||||||||||||||||||||||||
| 374 | ssh_remote_ipaddr(ssh), ssh_remote_port(ssh)); | - | ||||||||||||||||||||||||
| 375 | return never executed: -30;return -30;never executed: return -30; | 0 | ||||||||||||||||||||||||
| 376 | } | - | ||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||
| 378 | static int | - | ||||||||||||||||||||||||
| 379 | ssh_packet_start_discard(struct ssh *ssh, struct sshenc *enc, | - | ||||||||||||||||||||||||
| 380 | struct sshmac *mac, size_t mac_already, u_int discard) | - | ||||||||||||||||||||||||
| 381 | { | - | ||||||||||||||||||||||||
| 382 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 383 | int r; | - | ||||||||||||||||||||||||
| 384 | - | |||||||||||||||||||||||||
| 385 | if (enc ==
| 0 | ||||||||||||||||||||||||
| 386 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 387 | || !cipher_is_cbc(enc->cipher)
| 0 | ||||||||||||||||||||||||
| 388 | if ((
| 0 | ||||||||||||||||||||||||
| 389 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 390 | return never executed: -30;return -30;never executed: return -30; | 0 | ||||||||||||||||||||||||
| 391 | } | - | ||||||||||||||||||||||||
| 392 | - | |||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | - | |||||||||||||||||||||||||
| 396 | if (mac
| 0 | ||||||||||||||||||||||||
| 397 | state->packet_discard_mac = mac; | - | ||||||||||||||||||||||||
| 398 | state->packet_discard_mac_already = mac_already; | - | ||||||||||||||||||||||||
| 399 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 400 | if (sshbuf_len(state->input) >= discard
| 0 | ||||||||||||||||||||||||
| 401 | return never executed: ssh_packet_stop_discard(ssh);return ssh_packet_stop_discard(ssh);never executed: return ssh_packet_stop_discard(ssh); | 0 | ||||||||||||||||||||||||
| 402 | state->packet_discard = discard - sshbuf_len(state->input); | - | ||||||||||||||||||||||||
| 403 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 404 | } | - | ||||||||||||||||||||||||
| 405 | - | |||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||
| 408 | int | - | ||||||||||||||||||||||||
| 409 | ssh_packet_connection_is_on_socket(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 410 | { | - | ||||||||||||||||||||||||
| 411 | struct session_state *state; | - | ||||||||||||||||||||||||
| 412 | struct sockaddr_storage from, to; | - | ||||||||||||||||||||||||
| 413 | socklen_t fromlen, tolen; | - | ||||||||||||||||||||||||
| 414 | - | |||||||||||||||||||||||||
| 415 | if (ssh ==
| 0-96 | ||||||||||||||||||||||||
| 416 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 417 | || ssh->state ==
| 0-96 | ||||||||||||||||||||||||
| 418 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 419 | ) | - | ||||||||||||||||||||||||
| 420 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | state = ssh->state; | - | ||||||||||||||||||||||||
| 423 | if (state->connection_in == -1
| 0-96 | ||||||||||||||||||||||||
| 424 | return executed 96 times by 1 test: 0;return 0;Executed by:
executed 96 times by 1 test: return 0;Executed by:
| 96 | ||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | if (state->connection_in == state->connection_out
| 0 | ||||||||||||||||||||||||
| 427 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 428 | fromlen = sizeof(from); | - | ||||||||||||||||||||||||
| 429 | memset(&from, 0, sizeof(from)); | - | ||||||||||||||||||||||||
| 430 | if (getpeername(state->connection_in, (struct sockaddr *)&from,
| 0 | ||||||||||||||||||||||||
| 431 | &fromlen) < 0
| 0 | ||||||||||||||||||||||||
| 432 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 433 | tolen = sizeof(to); | - | ||||||||||||||||||||||||
| 434 | memset(&to, 0, sizeof(to)); | - | ||||||||||||||||||||||||
| 435 | if (getpeername(state->connection_out, (struct sockaddr *)&to,
| 0 | ||||||||||||||||||||||||
| 436 | &tolen) < 0
| 0 | ||||||||||||||||||||||||
| 437 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 438 | if (fromlen != tolen
| 0 | ||||||||||||||||||||||||
| 439 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 440 | if (from.ss_family !=
| 0 | ||||||||||||||||||||||||
| 441 | 2
| 0 | ||||||||||||||||||||||||
| 442 | && from.ss_family !=
| 0 | ||||||||||||||||||||||||
| 443 | 10
| 0 | ||||||||||||||||||||||||
| 444 | ) | - | ||||||||||||||||||||||||
| 445 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 446 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 447 | } | - | ||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||
| 449 | void | - | ||||||||||||||||||||||||
| 450 | ssh_packet_get_bytes(struct ssh *ssh, u_int64_t *ibytes, u_int64_t *obytes) | - | ||||||||||||||||||||||||
| 451 | { | - | ||||||||||||||||||||||||
| 452 | if (ibytes
| 0 | ||||||||||||||||||||||||
| 453 | * never executed: ibytes = ssh->state->p_read.bytes;*ibytes = ssh->state->p_read.bytes;never executed: *ibytes = ssh->state->p_read.bytes; | 0 | ||||||||||||||||||||||||
| 454 | if (obytes
| 0 | ||||||||||||||||||||||||
| 455 | * never executed: obytes = ssh->state->p_send.bytes;*obytes = ssh->state->p_send.bytes;never executed: *obytes = ssh->state->p_send.bytes; | 0 | ||||||||||||||||||||||||
| 456 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 457 | - | |||||||||||||||||||||||||
| 458 | int | - | ||||||||||||||||||||||||
| 459 | ssh_packet_connection_af(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 460 | { | - | ||||||||||||||||||||||||
| 461 | struct sockaddr_storage to; | - | ||||||||||||||||||||||||
| 462 | socklen_t tolen = sizeof(to); | - | ||||||||||||||||||||||||
| 463 | - | |||||||||||||||||||||||||
| 464 | memset(&to, 0, sizeof(to)); | - | ||||||||||||||||||||||||
| 465 | if (getsockname(ssh->state->connection_out, (struct sockaddr *)&to,
| 0 | ||||||||||||||||||||||||
| 466 | &tolen) < 0
| 0 | ||||||||||||||||||||||||
| 467 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 468 | - | |||||||||||||||||||||||||
| 469 | if (to.ss_family ==
| 0 | ||||||||||||||||||||||||
| 470 | 10
| 0 | ||||||||||||||||||||||||
| 471 | && | - | ||||||||||||||||||||||||
| 472 | - | |||||||||||||||||||||||||
| 473 | (
| 0 | ||||||||||||||||||||||||
| 474 | &((struct sockaddr_in6 *)&to)->sin6_addr
| 0 | ||||||||||||||||||||||||
| 475 | ); __a->__in6_u.__u6_addr32[0] == 0 && __a->__in6_u.__u6_addr32[1] == 0 && __a->__in6_u.__u6_addr32[2] == __bswap_32 (0xffff); }))
| 0 | ||||||||||||||||||||||||
| 476 | ) | - | ||||||||||||||||||||||||
| 477 | return never executed: return 2 ;never executed: return 2 ; | 0 | ||||||||||||||||||||||||
| 478 | 2 never executed: return 2 ; | 0 | ||||||||||||||||||||||||
| 479 | ; never executed: return 2 ; | 0 | ||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||
| 481 | return never executed: to.ss_family;return to.ss_family;never executed: return to.ss_family; | 0 | ||||||||||||||||||||||||
| 482 | } | - | ||||||||||||||||||||||||
| 483 | - | |||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||
| 485 | - | |||||||||||||||||||||||||
| 486 | void | - | ||||||||||||||||||||||||
| 487 | ssh_packet_set_nonblocking(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 488 | { | - | ||||||||||||||||||||||||
| 489 | - | |||||||||||||||||||||||||
| 490 | set_nonblock(ssh->state->connection_in); | - | ||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||
| 492 | if (ssh->state->connection_out != ssh->state->connection_in
| 0 | ||||||||||||||||||||||||
| 493 | set_nonblock(ssh->state->connection_out); never executed: set_nonblock(ssh->state->connection_out); | 0 | ||||||||||||||||||||||||
| 494 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 495 | - | |||||||||||||||||||||||||
| 496 | - | |||||||||||||||||||||||||
| 497 | - | |||||||||||||||||||||||||
| 498 | int | - | ||||||||||||||||||||||||
| 499 | ssh_packet_get_connection_in(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 500 | { | - | ||||||||||||||||||||||||
| 501 | return never executed: ssh->state->connection_in;return ssh->state->connection_in;never executed: return ssh->state->connection_in; | 0 | ||||||||||||||||||||||||
| 502 | } | - | ||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||
| 504 | - | |||||||||||||||||||||||||
| 505 | - | |||||||||||||||||||||||||
| 506 | int | - | ||||||||||||||||||||||||
| 507 | ssh_packet_get_connection_out(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 508 | { | - | ||||||||||||||||||||||||
| 509 | return never executed: ssh->state->connection_out;return ssh->state->connection_out;never executed: return ssh->state->connection_out; | 0 | ||||||||||||||||||||||||
| 510 | } | - | ||||||||||||||||||||||||
| 511 | - | |||||||||||||||||||||||||
| 512 | - | |||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||
| 514 | - | |||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||
| 516 | - | |||||||||||||||||||||||||
| 517 | const char * | - | ||||||||||||||||||||||||
| 518 | ssh_remote_ipaddr(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 519 | { | - | ||||||||||||||||||||||||
| 520 | int sock; | - | ||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||
| 523 | if (ssh->remote_ipaddr ==
| 0-96 | ||||||||||||||||||||||||
| 524 | ((void *)0)
| 0-96 | ||||||||||||||||||||||||
| 525 | ) { | - | ||||||||||||||||||||||||
| 526 | if (ssh_packet_connection_is_on_socket(ssh)
| 0-96 | ||||||||||||||||||||||||
| 527 | sock = ssh->state->connection_in; | - | ||||||||||||||||||||||||
| 528 | ssh->remote_ipaddr = get_peer_ipaddr(sock); | - | ||||||||||||||||||||||||
| 529 | ssh->remote_port = get_peer_port(sock); | - | ||||||||||||||||||||||||
| 530 | ssh->local_ipaddr = get_local_ipaddr(sock); | - | ||||||||||||||||||||||||
| 531 | ssh->local_port = get_local_port(sock); | - | ||||||||||||||||||||||||
| 532 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 533 | ssh->remote_ipaddr = | - | ||||||||||||||||||||||||
| 534 | (__extension__ (__builtin_constant_p (
| 0-96 | ||||||||||||||||||||||||
| 535 | "UNKNOWN"
| 0-96 | ||||||||||||||||||||||||
| 536 | )
| 0-96 | ||||||||||||||||||||||||
| 537 | "UNKNOWN"
| 0-96 | ||||||||||||||||||||||||
| 538 | ) + 1) - (size_t)(const void *)(
| 0-96 | ||||||||||||||||||||||||
| 539 | "UNKNOWN"
| 0-96 | ||||||||||||||||||||||||
| 540 | ) == 1)
| 0-96 | ||||||||||||||||||||||||
| 541 | "UNKNOWN"
| 0-96 | ||||||||||||||||||||||||
| 542 | ))[0] == '\0'
| 0-96 | ||||||||||||||||||||||||
| 543 | "UNKNOWN" | - | ||||||||||||||||||||||||
| 544 | ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void *)0)
executed 96 times by 1 test: __retval = (char *) memcpy (__retval, "UNKNOWN" , __len);Executed by:
| 0-96 | ||||||||||||||||||||||||
| 545 | "UNKNOWN" executed 96 times by 1 test: __retval = (char *) memcpy (__retval, "UNKNOWN" , __len);Executed by:
| 96 | ||||||||||||||||||||||||
| 546 | , __len); executed 96 times by 1 test: __retval; })) : __strdup (__retval = (char *) memcpy (__retval, "UNKNOWN" , __len);Executed by:
| 96 | ||||||||||||||||||||||||
| 547 | "UNKNOWN" | - | ||||||||||||||||||||||||
| 548 | ))) | - | ||||||||||||||||||||||||
| 549 | ; | - | ||||||||||||||||||||||||
| 550 | ssh->remote_port = 65535; | - | ||||||||||||||||||||||||
| 551 | ssh->local_ipaddr = | - | ||||||||||||||||||||||||
| 552 | (__extension__ (__builtin_constant_p (
| 0-96 | ||||||||||||||||||||||||
| 553 | "UNKNOWN"
| 0-96 | ||||||||||||||||||||||||
| 554 | )
| 0-96 | ||||||||||||||||||||||||
| 555 | "UNKNOWN"
| 0-96 | ||||||||||||||||||||||||
| 556 | ) + 1) - (size_t)(const void *)(
| 0-96 | ||||||||||||||||||||||||
| 557 | "UNKNOWN"
| 0-96 | ||||||||||||||||||||||||
| 558 | ) == 1)
| 0-96 | ||||||||||||||||||||||||
| 559 | "UNKNOWN"
| 0-96 | ||||||||||||||||||||||||
| 560 | ))[0] == '\0'
| 0-96 | ||||||||||||||||||||||||
| 561 | "UNKNOWN" | - | ||||||||||||||||||||||||
| 562 | ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void *)0)
executed 96 times by 1 test: __retval = (char *) memcpy (__retval, "UNKNOWN" , __len);Executed by:
| 0-96 | ||||||||||||||||||||||||
| 563 | "UNKNOWN" executed 96 times by 1 test: __retval = (char *) memcpy (__retval, "UNKNOWN" , __len);Executed by:
| 96 | ||||||||||||||||||||||||
| 564 | , __len); executed 96 times by 1 test: __retval; })) : __strdup (__retval = (char *) memcpy (__retval, "UNKNOWN" , __len);Executed by:
| 96 | ||||||||||||||||||||||||
| 565 | "UNKNOWN" | - | ||||||||||||||||||||||||
| 566 | ))) | - | ||||||||||||||||||||||||
| 567 | ; | - | ||||||||||||||||||||||||
| 568 | ssh->local_port = 65535; | - | ||||||||||||||||||||||||
| 569 | } executed 96 times by 1 test: end of blockExecuted by:
| 96 | ||||||||||||||||||||||||
| 570 | } | - | ||||||||||||||||||||||||
| 571 | return executed 96 times by 1 test: ssh->remote_ipaddr;return ssh->remote_ipaddr;Executed by:
executed 96 times by 1 test: return ssh->remote_ipaddr;Executed by:
| 96 | ||||||||||||||||||||||||
| 572 | } | - | ||||||||||||||||||||||||
| 573 | - | |||||||||||||||||||||||||
| 574 | - | |||||||||||||||||||||||||
| 575 | - | |||||||||||||||||||||||||
| 576 | int | - | ||||||||||||||||||||||||
| 577 | ssh_remote_port(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 578 | { | - | ||||||||||||||||||||||||
| 579 | (void)ssh_remote_ipaddr(ssh); | - | ||||||||||||||||||||||||
| 580 | return never executed: ssh->remote_port;return ssh->remote_port;never executed: return ssh->remote_port; | 0 | ||||||||||||||||||||||||
| 581 | } | - | ||||||||||||||||||||||||
| 582 | - | |||||||||||||||||||||||||
| 583 | - | |||||||||||||||||||||||||
| 584 | - | |||||||||||||||||||||||||
| 585 | - | |||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||
| 587 | - | |||||||||||||||||||||||||
| 588 | const char * | - | ||||||||||||||||||||||||
| 589 | ssh_local_ipaddr(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 590 | { | - | ||||||||||||||||||||||||
| 591 | (void)ssh_remote_ipaddr(ssh); | - | ||||||||||||||||||||||||
| 592 | return never executed: ssh->local_ipaddr;return ssh->local_ipaddr;never executed: return ssh->local_ipaddr; | 0 | ||||||||||||||||||||||||
| 593 | } | - | ||||||||||||||||||||||||
| 594 | - | |||||||||||||||||||||||||
| 595 | - | |||||||||||||||||||||||||
| 596 | - | |||||||||||||||||||||||||
| 597 | int | - | ||||||||||||||||||||||||
| 598 | ssh_local_port(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 599 | { | - | ||||||||||||||||||||||||
| 600 | (void)ssh_remote_ipaddr(ssh); | - | ||||||||||||||||||||||||
| 601 | return never executed: ssh->local_port;return ssh->local_port;never executed: return ssh->local_port; | 0 | ||||||||||||||||||||||||
| 602 | } | - | ||||||||||||||||||||||||
| 603 | - | |||||||||||||||||||||||||
| 604 | - | |||||||||||||||||||||||||
| 605 | const char * | - | ||||||||||||||||||||||||
| 606 | ssh_packet_rdomain_in(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 607 | { | - | ||||||||||||||||||||||||
| 608 | if (ssh->rdomain_in !=
| 0 | ||||||||||||||||||||||||
| 609 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 610 | ) | - | ||||||||||||||||||||||||
| 611 | return never executed: ssh->rdomain_in;return ssh->rdomain_in;never executed: return ssh->rdomain_in; | 0 | ||||||||||||||||||||||||
| 612 | if (!ssh_packet_connection_is_on_socket(ssh)
| 0 | ||||||||||||||||||||||||
| 613 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 614 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 615 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 616 | ssh->rdomain_in = get_rdomain(ssh->state->connection_in); | - | ||||||||||||||||||||||||
| 617 | return never executed: ssh->rdomain_in;return ssh->rdomain_in;never executed: return ssh->rdomain_in; | 0 | ||||||||||||||||||||||||
| 618 | } | - | ||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||
| 620 | - | |||||||||||||||||||||||||
| 621 | - | |||||||||||||||||||||||||
| 622 | static void | - | ||||||||||||||||||||||||
| 623 | ssh_packet_close_internal(struct ssh *ssh, int do_close) | - | ||||||||||||||||||||||||
| 624 | { | - | ||||||||||||||||||||||||
| 625 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 626 | u_int mode; | - | ||||||||||||||||||||||||
| 627 | - | |||||||||||||||||||||||||
| 628 | if (!state->initialized
| 0-96 | ||||||||||||||||||||||||
| 629 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 630 | state->initialized = 0; | - | ||||||||||||||||||||||||
| 631 | if (do_close
| 0-96 | ||||||||||||||||||||||||
| 632 | if (state->connection_in == state->connection_out
| 0-96 | ||||||||||||||||||||||||
| 633 | close(state->connection_out); | - | ||||||||||||||||||||||||
| 634 | } executed 96 times by 1 test: else {end of blockExecuted by:
| 96 | ||||||||||||||||||||||||
| 635 | close(state->connection_in); | - | ||||||||||||||||||||||||
| 636 | close(state->connection_out); | - | ||||||||||||||||||||||||
| 637 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 638 | } | - | ||||||||||||||||||||||||
| 639 | sshbuf_free(state->input); | - | ||||||||||||||||||||||||
| 640 | sshbuf_free(state->output); | - | ||||||||||||||||||||||||
| 641 | sshbuf_free(state->outgoing_packet); | - | ||||||||||||||||||||||||
| 642 | sshbuf_free(state->incoming_packet); | - | ||||||||||||||||||||||||
| 643 | for (mode = 0; mode < MODE_MAX
| 96-192 | ||||||||||||||||||||||||
| 644 | kex_free_newkeys(state->newkeys[mode]); | - | ||||||||||||||||||||||||
| 645 | state->newkeys[mode] = | - | ||||||||||||||||||||||||
| 646 | ((void *)0) | - | ||||||||||||||||||||||||
| 647 | ; | - | ||||||||||||||||||||||||
| 648 | ssh_clear_newkeys(ssh, mode); | - | ||||||||||||||||||||||||
| 649 | } executed 192 times by 1 test: end of blockExecuted by:
| 192 | ||||||||||||||||||||||||
| 650 | - | |||||||||||||||||||||||||
| 651 | if (do_close
| 0-96 | ||||||||||||||||||||||||
| 652 | sshbuf_free(state->compression_buffer); | - | ||||||||||||||||||||||||
| 653 | if (state->compression_out_started
| 0 | ||||||||||||||||||||||||
| 654 | z_streamp stream = &state->compression_out_stream; | - | ||||||||||||||||||||||||
| 655 | debug("compress outgoing: " | - | ||||||||||||||||||||||||
| 656 | "raw data %llu, compressed %llu, factor %.2f", | - | ||||||||||||||||||||||||
| 657 | (unsigned long long)stream->total_in, | - | ||||||||||||||||||||||||
| 658 | (unsigned long long)stream->total_out, | - | ||||||||||||||||||||||||
| 659 | stream->total_in == 0 ? 0.0 : | - | ||||||||||||||||||||||||
| 660 | (double) stream->total_out / stream->total_in); | - | ||||||||||||||||||||||||
| 661 | if (state->compression_out_failures == 0
| 0 | ||||||||||||||||||||||||
| 662 | deflateEnd(stream); never executed: deflateEnd(stream); | 0 | ||||||||||||||||||||||||
| 663 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 664 | if (state->compression_in_started
| 0 | ||||||||||||||||||||||||
| 665 | z_streamp stream = &state->compression_in_stream; | - | ||||||||||||||||||||||||
| 666 | debug("compress incoming: " | - | ||||||||||||||||||||||||
| 667 | "raw data %llu, compressed %llu, factor %.2f", | - | ||||||||||||||||||||||||
| 668 | (unsigned long long)stream->total_out, | - | ||||||||||||||||||||||||
| 669 | (unsigned long long)stream->total_in, | - | ||||||||||||||||||||||||
| 670 | stream->total_out == 0 ? 0.0 : | - | ||||||||||||||||||||||||
| 671 | (double) stream->total_in / stream->total_out); | - | ||||||||||||||||||||||||
| 672 | if (state->compression_in_failures == 0
| 0 | ||||||||||||||||||||||||
| 673 | inflateEnd(stream); never executed: inflateEnd(stream); | 0 | ||||||||||||||||||||||||
| 674 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 675 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 676 | cipher_free(state->send_context); | - | ||||||||||||||||||||||||
| 677 | cipher_free(state->receive_context); | - | ||||||||||||||||||||||||
| 678 | state->send_context = state->receive_context = | - | ||||||||||||||||||||||||
| 679 | ((void *)0) | - | ||||||||||||||||||||||||
| 680 | ; | - | ||||||||||||||||||||||||
| 681 | if (do_close
| 0-96 | ||||||||||||||||||||||||
| 682 | free(ssh->local_ipaddr); | - | ||||||||||||||||||||||||
| 683 | ssh->local_ipaddr = | - | ||||||||||||||||||||||||
| 684 | ((void *)0) | - | ||||||||||||||||||||||||
| 685 | ; | - | ||||||||||||||||||||||||
| 686 | free(ssh->remote_ipaddr); | - | ||||||||||||||||||||||||
| 687 | ssh->remote_ipaddr = | - | ||||||||||||||||||||||||
| 688 | ((void *)0) | - | ||||||||||||||||||||||||
| 689 | ; | - | ||||||||||||||||||||||||
| 690 | free(ssh->state); | - | ||||||||||||||||||||||||
| 691 | ssh->state = | - | ||||||||||||||||||||||||
| 692 | ((void *)0) | - | ||||||||||||||||||||||||
| 693 | ; | - | ||||||||||||||||||||||||
| 694 | } executed 96 times by 1 test: end of blockExecuted by:
| 96 | ||||||||||||||||||||||||
| 695 | } executed 96 times by 1 test: end of blockExecuted by:
| 96 | ||||||||||||||||||||||||
| 696 | - | |||||||||||||||||||||||||
| 697 | void | - | ||||||||||||||||||||||||
| 698 | ssh_packet_close(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 699 | { | - | ||||||||||||||||||||||||
| 700 | ssh_packet_close_internal(ssh, 1); | - | ||||||||||||||||||||||||
| 701 | } executed 96 times by 1 test: end of blockExecuted by:
| 96 | ||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||
| 703 | void | - | ||||||||||||||||||||||||
| 704 | ssh_packet_clear_keys(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 705 | { | - | ||||||||||||||||||||||||
| 706 | ssh_packet_close_internal(ssh, 0); | - | ||||||||||||||||||||||||
| 707 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 708 | - | |||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||
| 710 | - | |||||||||||||||||||||||||
| 711 | void | - | ||||||||||||||||||||||||
| 712 | ssh_packet_set_protocol_flags(struct ssh *ssh, u_int protocol_flags) | - | ||||||||||||||||||||||||
| 713 | { | - | ||||||||||||||||||||||||
| 714 | ssh->state->remote_protocol_flags = protocol_flags; | - | ||||||||||||||||||||||||
| 715 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 716 | - | |||||||||||||||||||||||||
| 717 | - | |||||||||||||||||||||||||
| 718 | - | |||||||||||||||||||||||||
| 719 | u_int | - | ||||||||||||||||||||||||
| 720 | ssh_packet_get_protocol_flags(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 721 | { | - | ||||||||||||||||||||||||
| 722 | return never executed: ssh->state->remote_protocol_flags;return ssh->state->remote_protocol_flags;never executed: return ssh->state->remote_protocol_flags; | 0 | ||||||||||||||||||||||||
| 723 | } | - | ||||||||||||||||||||||||
| 724 | - | |||||||||||||||||||||||||
| 725 | - | |||||||||||||||||||||||||
| 726 | - | |||||||||||||||||||||||||
| 727 | - | |||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||
| 729 | - | |||||||||||||||||||||||||
| 730 | static int | - | ||||||||||||||||||||||||
| 731 | ssh_packet_init_compression(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 732 | { | - | ||||||||||||||||||||||||
| 733 | if (!ssh->state->compression_buffer
| 0 | ||||||||||||||||||||||||
| 734 | ((
| 0 | ||||||||||||||||||||||||
| 735 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 736 | )
| 0 | ||||||||||||||||||||||||
| 737 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||
| 738 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 739 | } | - | ||||||||||||||||||||||||
| 740 | - | |||||||||||||||||||||||||
| 741 | static int | - | ||||||||||||||||||||||||
| 742 | start_compression_out(struct ssh *ssh, int level) | - | ||||||||||||||||||||||||
| 743 | { | - | ||||||||||||||||||||||||
| 744 | if (level < 1
| 0 | ||||||||||||||||||||||||
| 745 | return never executed: -10;return -10;never executed: return -10; | 0 | ||||||||||||||||||||||||
| 746 | debug("Enabling compression at level %d.", level); | - | ||||||||||||||||||||||||
| 747 | if (ssh->state->compression_out_started == 1
| 0 | ||||||||||||||||||||||||
| 748 | deflateEnd(&ssh->state->compression_out_stream); never executed: deflateEnd(&ssh->state->compression_out_stream); | 0 | ||||||||||||||||||||||||
| 749 | switch ( | - | ||||||||||||||||||||||||
| 750 | deflateInit_(( | - | ||||||||||||||||||||||||
| 751 | &ssh->state->compression_out_stream | - | ||||||||||||||||||||||||
| 752 | ), ( | - | ||||||||||||||||||||||||
| 753 | level | - | ||||||||||||||||||||||||
| 754 | ), "1.2.8", (int)sizeof(z_stream)) | - | ||||||||||||||||||||||||
| 755 | ) { | - | ||||||||||||||||||||||||
| 756 | case never executed: case 0 :never executed: case 0 : | 0 | ||||||||||||||||||||||||
| 757 | 0 never executed: case 0 : | 0 | ||||||||||||||||||||||||
| 758 | : never executed: case 0 : | 0 | ||||||||||||||||||||||||
| 759 | ssh->state->compression_out_started = 1; | - | ||||||||||||||||||||||||
| 760 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 761 | case never executed: case (-4) :never executed: case (-4) : | 0 | ||||||||||||||||||||||||
| 762 | (-4) never executed: case (-4) : | 0 | ||||||||||||||||||||||||
| 763 | : never executed: case (-4) : | 0 | ||||||||||||||||||||||||
| 764 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||
| 765 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 766 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 767 | } | - | ||||||||||||||||||||||||
| 768 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 769 | } | - | ||||||||||||||||||||||||
| 770 | - | |||||||||||||||||||||||||
| 771 | static int | - | ||||||||||||||||||||||||
| 772 | start_compression_in(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 773 | { | - | ||||||||||||||||||||||||
| 774 | if (ssh->state->compression_in_started == 1
| 0 | ||||||||||||||||||||||||
| 775 | inflateEnd(&ssh->state->compression_in_stream); never executed: inflateEnd(&ssh->state->compression_in_stream); | 0 | ||||||||||||||||||||||||
| 776 | switch ( | - | ||||||||||||||||||||||||
| 777 | inflateInit_(( | - | ||||||||||||||||||||||||
| 778 | &ssh->state->compression_in_stream | - | ||||||||||||||||||||||||
| 779 | ), "1.2.8", (int)sizeof(z_stream)) | - | ||||||||||||||||||||||||
| 780 | ) { | - | ||||||||||||||||||||||||
| 781 | case never executed: case 0 :never executed: case 0 : | 0 | ||||||||||||||||||||||||
| 782 | 0 never executed: case 0 : | 0 | ||||||||||||||||||||||||
| 783 | : never executed: case 0 : | 0 | ||||||||||||||||||||||||
| 784 | ssh->state->compression_in_started = 1; | - | ||||||||||||||||||||||||
| 785 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 786 | case never executed: case (-4) :never executed: case (-4) : | 0 | ||||||||||||||||||||||||
| 787 | (-4) never executed: case (-4) : | 0 | ||||||||||||||||||||||||
| 788 | : never executed: case (-4) : | 0 | ||||||||||||||||||||||||
| 789 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||
| 790 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 791 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 792 | } | - | ||||||||||||||||||||||||
| 793 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 794 | } | - | ||||||||||||||||||||||||
| 795 | - | |||||||||||||||||||||||||
| 796 | - | |||||||||||||||||||||||||
| 797 | static int | - | ||||||||||||||||||||||||
| 798 | compress_buffer(struct ssh *ssh, struct sshbuf *in, struct sshbuf *out) | - | ||||||||||||||||||||||||
| 799 | { | - | ||||||||||||||||||||||||
| 800 | u_char buf[4096]; | - | ||||||||||||||||||||||||
| 801 | int r, status; | - | ||||||||||||||||||||||||
| 802 | - | |||||||||||||||||||||||||
| 803 | if (ssh->state->compression_out_started != 1
| 0 | ||||||||||||||||||||||||
| 804 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 805 | - | |||||||||||||||||||||||||
| 806 | - | |||||||||||||||||||||||||
| 807 | if (sshbuf_len(in) == 0
| 0 | ||||||||||||||||||||||||
| 808 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 809 | - | |||||||||||||||||||||||||
| 810 | - | |||||||||||||||||||||||||
| 811 | if ((
| 0 | ||||||||||||||||||||||||
| 812 | sshbuf_mutable_ptr(in)) ==
| 0 | ||||||||||||||||||||||||
| 813 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 814 | ) | - | ||||||||||||||||||||||||
| 815 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 816 | ssh->state->compression_out_stream.avail_in = sshbuf_len(in); | - | ||||||||||||||||||||||||
| 817 | - | |||||||||||||||||||||||||
| 818 | - | |||||||||||||||||||||||||
| 819 | do { | - | ||||||||||||||||||||||||
| 820 | - | |||||||||||||||||||||||||
| 821 | ssh->state->compression_out_stream.next_out = buf; | - | ||||||||||||||||||||||||
| 822 | ssh->state->compression_out_stream.avail_out = sizeof(buf); | - | ||||||||||||||||||||||||
| 823 | - | |||||||||||||||||||||||||
| 824 | - | |||||||||||||||||||||||||
| 825 | status = deflate(&ssh->state->compression_out_stream, | - | ||||||||||||||||||||||||
| 826 | - | |||||||||||||||||||||||||
| 827 | 1 | - | ||||||||||||||||||||||||
| 828 | ); | - | ||||||||||||||||||||||||
| 829 | switch (status) { | - | ||||||||||||||||||||||||
| 830 | case never executed: case (-4) :never executed: case (-4) : | 0 | ||||||||||||||||||||||||
| 831 | (-4) never executed: case (-4) : | 0 | ||||||||||||||||||||||||
| 832 | : never executed: case (-4) : | 0 | ||||||||||||||||||||||||
| 833 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||
| 834 | case never executed: case 0 :never executed: case 0 : | 0 | ||||||||||||||||||||||||
| 835 | 0 never executed: case 0 : | 0 | ||||||||||||||||||||||||
| 836 | : never executed: case 0 : | 0 | ||||||||||||||||||||||||
| 837 | - | |||||||||||||||||||||||||
| 838 | if ((
| 0 | ||||||||||||||||||||||||
| 839 | ssh->state->compression_out_stream.avail_out)) != 0
| 0 | ||||||||||||||||||||||||
| 840 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 841 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 842 | case never executed: case (-2) :never executed: case (-2) : | 0 | ||||||||||||||||||||||||
| 843 | (-2) never executed: case (-2) : | 0 | ||||||||||||||||||||||||
| 844 | : never executed: case (-2) : | 0 | ||||||||||||||||||||||||
| 845 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 846 | ssh->state->compression_out_failures++; | - | ||||||||||||||||||||||||
| 847 | return never executed: -4;return -4;never executed: return -4; | 0 | ||||||||||||||||||||||||
| 848 | } | - | ||||||||||||||||||||||||
| 849 | } while (ssh->state->compression_out_stream.avail_out == 0
| 0 | ||||||||||||||||||||||||
| 850 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 851 | } | - | ||||||||||||||||||||||||
| 852 | - | |||||||||||||||||||||||||
| 853 | static int | - | ||||||||||||||||||||||||
| 854 | uncompress_buffer(struct ssh *ssh, struct sshbuf *in, struct sshbuf *out) | - | ||||||||||||||||||||||||
| 855 | { | - | ||||||||||||||||||||||||
| 856 | u_char buf[4096]; | - | ||||||||||||||||||||||||
| 857 | int r, status; | - | ||||||||||||||||||||||||
| 858 | - | |||||||||||||||||||||||||
| 859 | if (ssh->state->compression_in_started != 1
| 0 | ||||||||||||||||||||||||
| 860 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 861 | - | |||||||||||||||||||||||||
| 862 | if ((
| 0 | ||||||||||||||||||||||||
| 863 | sshbuf_mutable_ptr(in)) ==
| 0 | ||||||||||||||||||||||||
| 864 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 865 | ) | - | ||||||||||||||||||||||||
| 866 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 867 | ssh->state->compression_in_stream.avail_in = sshbuf_len(in); | - | ||||||||||||||||||||||||
| 868 | - | |||||||||||||||||||||||||
| 869 | for (;;) { | - | ||||||||||||||||||||||||
| 870 | - | |||||||||||||||||||||||||
| 871 | ssh->state->compression_in_stream.next_out = buf; | - | ||||||||||||||||||||||||
| 872 | ssh->state->compression_in_stream.avail_out = sizeof(buf); | - | ||||||||||||||||||||||||
| 873 | - | |||||||||||||||||||||||||
| 874 | status = inflate(&ssh->state->compression_in_stream, | - | ||||||||||||||||||||||||
| 875 | - | |||||||||||||||||||||||||
| 876 | 1 | - | ||||||||||||||||||||||||
| 877 | ); | - | ||||||||||||||||||||||||
| 878 | switch (status) { | - | ||||||||||||||||||||||||
| 879 | case never executed: case 0 :never executed: case 0 : | 0 | ||||||||||||||||||||||||
| 880 | 0 never executed: case 0 : | 0 | ||||||||||||||||||||||||
| 881 | : never executed: case 0 : | 0 | ||||||||||||||||||||||||
| 882 | if ((
| 0 | ||||||||||||||||||||||||
| 883 | ssh->state->compression_in_stream.avail_out)) != 0
| 0 | ||||||||||||||||||||||||
| 884 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 885 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 886 | case never executed: case (-5) :never executed: case (-5) : | 0 | ||||||||||||||||||||||||
| 887 | (-5) never executed: case (-5) : | 0 | ||||||||||||||||||||||||
| 888 | : never executed: case (-5) : | 0 | ||||||||||||||||||||||||
| 889 | - | |||||||||||||||||||||||||
| 890 | - | |||||||||||||||||||||||||
| 891 | - | |||||||||||||||||||||||||
| 892 | - | |||||||||||||||||||||||||
| 893 | - | |||||||||||||||||||||||||
| 894 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 895 | case never executed: case (-3) :never executed: case (-3) : | 0 | ||||||||||||||||||||||||
| 896 | (-3) never executed: case (-3) : | 0 | ||||||||||||||||||||||||
| 897 | : never executed: case (-3) : | 0 | ||||||||||||||||||||||||
| 898 | return never executed: -4;return -4;never executed: return -4; | 0 | ||||||||||||||||||||||||
| 899 | case never executed: case (-4) :never executed: case (-4) : | 0 | ||||||||||||||||||||||||
| 900 | (-4) never executed: case (-4) : | 0 | ||||||||||||||||||||||||
| 901 | : never executed: case (-4) : | 0 | ||||||||||||||||||||||||
| 902 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||
| 903 | case never executed: case (-2) :never executed: case (-2) : | 0 | ||||||||||||||||||||||||
| 904 | (-2) never executed: case (-2) : | 0 | ||||||||||||||||||||||||
| 905 | : never executed: case (-2) : | 0 | ||||||||||||||||||||||||
| 906 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 907 | ssh->state->compression_in_failures++; | - | ||||||||||||||||||||||||
| 908 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 909 | } | - | ||||||||||||||||||||||||
| 910 | } | - | ||||||||||||||||||||||||
| 911 | - | |||||||||||||||||||||||||
| 912 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 913 | - | |||||||||||||||||||||||||
| 914 | void | - | ||||||||||||||||||||||||
| 915 | ssh_clear_newkeys(struct ssh *ssh, int mode) | - | ||||||||||||||||||||||||
| 916 | { | - | ||||||||||||||||||||||||
| 917 | if (ssh->kex
| 0-192 | ||||||||||||||||||||||||
| 918 | kex_free_newkeys(ssh->kex->newkeys[mode]); | - | ||||||||||||||||||||||||
| 919 | ssh->kex->newkeys[mode] = | - | ||||||||||||||||||||||||
| 920 | ((void *)0) | - | ||||||||||||||||||||||||
| 921 | ; | - | ||||||||||||||||||||||||
| 922 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 923 | } executed 192 times by 1 test: end of blockExecuted by:
| 192 | ||||||||||||||||||||||||
| 924 | - | |||||||||||||||||||||||||
| 925 | int | - | ||||||||||||||||||||||||
| 926 | ssh_set_newkeys(struct ssh *ssh, int mode) | - | ||||||||||||||||||||||||
| 927 | { | - | ||||||||||||||||||||||||
| 928 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 929 | struct sshenc *enc; | - | ||||||||||||||||||||||||
| 930 | struct sshmac *mac; | - | ||||||||||||||||||||||||
| 931 | struct sshcomp *comp; | - | ||||||||||||||||||||||||
| 932 | struct sshcipher_ctx **ccp; | - | ||||||||||||||||||||||||
| 933 | struct packet_state *ps; | - | ||||||||||||||||||||||||
| 934 | u_int64_t *max_blocks; | - | ||||||||||||||||||||||||
| 935 | const char *wmsg; | - | ||||||||||||||||||||||||
| 936 | int r, crypt_type; | - | ||||||||||||||||||||||||
| 937 | - | |||||||||||||||||||||||||
| 938 | debug2("set_newkeys: mode %d", mode); | - | ||||||||||||||||||||||||
| 939 | - | |||||||||||||||||||||||||
| 940 | if (mode == MODE_OUT
| 352 | ||||||||||||||||||||||||
| 941 | ccp = &state->send_context; | - | ||||||||||||||||||||||||
| 942 | crypt_type = 1; | - | ||||||||||||||||||||||||
| 943 | ps = &state->p_send; | - | ||||||||||||||||||||||||
| 944 | max_blocks = &state->max_blocks_out; | - | ||||||||||||||||||||||||
| 945 | } executed 352 times by 1 test: else {end of blockExecuted by:
| 352 | ||||||||||||||||||||||||
| 946 | ccp = &state->receive_context; | - | ||||||||||||||||||||||||
| 947 | crypt_type = 0; | - | ||||||||||||||||||||||||
| 948 | ps = &state->p_read; | - | ||||||||||||||||||||||||
| 949 | max_blocks = &state->max_blocks_in; | - | ||||||||||||||||||||||||
| 950 | } executed 352 times by 1 test: end of blockExecuted by:
| 352 | ||||||||||||||||||||||||
| 951 | if (state->newkeys[mode] !=
| 192-512 | ||||||||||||||||||||||||
| 952 | ((void *)0)
| 192-512 | ||||||||||||||||||||||||
| 953 | ) { | - | ||||||||||||||||||||||||
| 954 | debug("set_newkeys: rekeying, input %llu bytes %llu blocks, " | - | ||||||||||||||||||||||||
| 955 | "output %llu bytes %llu blocks", | - | ||||||||||||||||||||||||
| 956 | (unsigned long long)state->p_read.bytes, | - | ||||||||||||||||||||||||
| 957 | (unsigned long long)state->p_read.blocks, | - | ||||||||||||||||||||||||
| 958 | (unsigned long long)state->p_send.bytes, | - | ||||||||||||||||||||||||
| 959 | (unsigned long long)state->p_send.blocks); | - | ||||||||||||||||||||||||
| 960 | cipher_free(*ccp); | - | ||||||||||||||||||||||||
| 961 | *ccp = | - | ||||||||||||||||||||||||
| 962 | ((void *)0) | - | ||||||||||||||||||||||||
| 963 | ; | - | ||||||||||||||||||||||||
| 964 | kex_free_newkeys(state->newkeys[mode]); | - | ||||||||||||||||||||||||
| 965 | state->newkeys[mode] = | - | ||||||||||||||||||||||||
| 966 | ((void *)0) | - | ||||||||||||||||||||||||
| 967 | ; | - | ||||||||||||||||||||||||
| 968 | } executed 512 times by 1 test: end of blockExecuted by:
| 512 | ||||||||||||||||||||||||
| 969 | - | |||||||||||||||||||||||||
| 970 | ps->packets = ps->blocks = 0; | - | ||||||||||||||||||||||||
| 971 | - | |||||||||||||||||||||||||
| 972 | if ((
| 0-704 | ||||||||||||||||||||||||
| 973 | ((void *)0)
| 0-704 | ||||||||||||||||||||||||
| 974 | ) | - | ||||||||||||||||||||||||
| 975 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 976 | ssh->kex->newkeys[mode] = | - | ||||||||||||||||||||||||
| 977 | ((void *)0) | - | ||||||||||||||||||||||||
| 978 | ; | - | ||||||||||||||||||||||||
| 979 | enc = &state->newkeys[mode]->enc; | - | ||||||||||||||||||||||||
| 980 | mac = &state->newkeys[mode]->mac; | - | ||||||||||||||||||||||||
| 981 | comp = &state->newkeys[mode]->comp; | - | ||||||||||||||||||||||||
| 982 | if (cipher_authlen(enc->cipher) == 0
| 0-704 | ||||||||||||||||||||||||
| 983 | if ((
| 0 | ||||||||||||||||||||||||
| 984 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 985 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 986 | mac->enabled = 1; | - | ||||||||||||||||||||||||
| 987 | ; | - | ||||||||||||||||||||||||
| 988 | if ((
| 0-704 | ||||||||||||||||||||||||
| 989 | enc->iv, enc->iv_len, crypt_type)) != 0
| 0-704 | ||||||||||||||||||||||||
| 990 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 991 | if (!state->cipher_warning_done
| 0-704 | ||||||||||||||||||||||||
| 992 | (
| 0-704 | ||||||||||||||||||||||||
| 993 | ((void *)0)
| 0-704 | ||||||||||||||||||||||||
| 994 | ) { | - | ||||||||||||||||||||||||
| 995 | error("Warning: %s", wmsg); | - | ||||||||||||||||||||||||
| 996 | state->cipher_warning_done = 1; | - | ||||||||||||||||||||||||
| 997 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 998 | - | |||||||||||||||||||||||||
| 999 | - | |||||||||||||||||||||||||
| 1000 | - | |||||||||||||||||||||||||
| 1001 | - | |||||||||||||||||||||||||
| 1002 | if ((comp->type == 1
| 0-704 | ||||||||||||||||||||||||
| 1003 | (comp->type == 2
| 0-704 | ||||||||||||||||||||||||
| 1004 | state->after_authentication
| 0 | ||||||||||||||||||||||||
| 1005 | if ((
| 0 | ||||||||||||||||||||||||
| 1006 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1007 | if (mode == MODE_OUT
| 0 | ||||||||||||||||||||||||
| 1008 | if ((
| 0 | ||||||||||||||||||||||||
| 1009 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1010 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1011 | if ((
| 0 | ||||||||||||||||||||||||
| 1012 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1013 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1014 | comp->enabled = 1; | - | ||||||||||||||||||||||||
| 1015 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1016 | - | |||||||||||||||||||||||||
| 1017 | - | |||||||||||||||||||||||||
| 1018 | - | |||||||||||||||||||||||||
| 1019 | - | |||||||||||||||||||||||||
| 1020 | - | |||||||||||||||||||||||||
| 1021 | if (enc->block_size >= 16
| 0-704 | ||||||||||||||||||||||||
| 1022 | * never executed: max_blocks = (u_int64_t)1 << (enc->block_size*2);*max_blocks = (u_int64_t)1 << (enc->block_size*2);never executed: *max_blocks = (u_int64_t)1 << (enc->block_size*2); | 0 | ||||||||||||||||||||||||
| 1023 | else | - | ||||||||||||||||||||||||
| 1024 | * executed 704 times by 1 test: max_blocks = ((u_int64_t)1 << 30) / enc->block_size;*max_blocks = ((u_int64_t)1 << 30) / enc->block_size;Executed by:
executed 704 times by 1 test: *max_blocks = ((u_int64_t)1 << 30) / enc->block_size;Executed by:
| 704 | ||||||||||||||||||||||||
| 1025 | if (state->rekey_limit
| 0-704 | ||||||||||||||||||||||||
| 1026 | * never executed: max_blocks = (((**max_blocks = (((*max_blocks) < (state->rekey_limit / enc->block_size)) ? (*max_blocks) : (state->rekey_limit / enc->block_size)) ;
never executed: *max_blocks = (((*max_blocks) < (state->rekey_limit / enc->block_size)) ? (*max_blocks) : (state->rekey_limit / enc->block_size)) ; | 0 | ||||||||||||||||||||||||
| 1027 | ; never executed: *max_blocks = (((*max_blocks) < (state->rekey_limit / enc->block_size)) ? (*max_blocks) : (state->rekey_limit / enc->block_size)) ; | 0 | ||||||||||||||||||||||||
| 1028 | debug("rekey after %llu blocks", (unsigned long long)*max_blocks); | - | ||||||||||||||||||||||||
| 1029 | return executed 704 times by 1 test: 0;return 0;Executed by:
executed 704 times by 1 test: return 0;Executed by:
| 704 | ||||||||||||||||||||||||
| 1030 | } | - | ||||||||||||||||||||||||
| 1031 | - | |||||||||||||||||||||||||
| 1032 | - | |||||||||||||||||||||||||
| 1033 | static int | - | ||||||||||||||||||||||||
| 1034 | ssh_packet_need_rekeying(struct ssh *ssh, u_int outbound_packet_len) | - | ||||||||||||||||||||||||
| 1035 | { | - | ||||||||||||||||||||||||
| 1036 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 1037 | u_int32_t out_blocks; | - | ||||||||||||||||||||||||
| 1038 | - | |||||||||||||||||||||||||
| 1039 | - | |||||||||||||||||||||||||
| 1040 | if (!state->after_authentication
| 208-832 | ||||||||||||||||||||||||
| 1041 | return executed 832 times by 1 test: 0;return 0;Executed by:
executed 832 times by 1 test: return 0;Executed by:
| 832 | ||||||||||||||||||||||||
| 1042 | - | |||||||||||||||||||||||||
| 1043 | - | |||||||||||||||||||||||||
| 1044 | if (ssh->kex ==
| 0-208 | ||||||||||||||||||||||||
| 1045 | ((void *)0)
| 0-208 | ||||||||||||||||||||||||
| 1046 | || ssh_packet_is_rekeying(ssh)
| 32-176 | ||||||||||||||||||||||||
| 1047 | return executed 176 times by 1 test: 0;return 0;Executed by:
executed 176 times by 1 test: return 0;Executed by:
| 176 | ||||||||||||||||||||||||
| 1048 | - | |||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||
| 1050 | if (ssh->compat & 0x00008000
| 0-32 | ||||||||||||||||||||||||
| 1051 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1052 | - | |||||||||||||||||||||||||
| 1053 | - | |||||||||||||||||||||||||
| 1054 | - | |||||||||||||||||||||||||
| 1055 | - | |||||||||||||||||||||||||
| 1056 | - | |||||||||||||||||||||||||
| 1057 | if (state->p_send.packets == 0
| 0-32 | ||||||||||||||||||||||||
| 1058 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1059 | - | |||||||||||||||||||||||||
| 1060 | - | |||||||||||||||||||||||||
| 1061 | if (state->rekey_interval != 0
| 0-32 | ||||||||||||||||||||||||
| 1062 | (
| 0 | ||||||||||||||||||||||||
| 1063 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 1064 | - | |||||||||||||||||||||||||
| 1065 | - | |||||||||||||||||||||||||
| 1066 | - | |||||||||||||||||||||||||
| 1067 | - | |||||||||||||||||||||||||
| 1068 | - | |||||||||||||||||||||||||
| 1069 | if (state->p_send.packets > (1U<<31)
| 0-32 | ||||||||||||||||||||||||
| 1070 | state->p_read.packets > (1U<<31)
| 0-32 | ||||||||||||||||||||||||
| 1071 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 1072 | - | |||||||||||||||||||||||||
| 1073 | - | |||||||||||||||||||||||||
| 1074 | out_blocks = ((((outbound_packet_len)+((state->newkeys[MODE_OUT]->enc.block_size)-1))/(state->newkeys[MODE_OUT]->enc.block_size))*(state->newkeys[MODE_OUT]->enc.block_size)) | - | ||||||||||||||||||||||||
| 1075 | ; | - | ||||||||||||||||||||||||
| 1076 | return executed 32 times by 1 test: (state->max_blocks_outreturn (state->max_blocks_out && (state->p_send.blocks + out_blocks > state->max_blocks_out)) || (state->max_blocks_in && (state->p_read.blocks > state->max_blocks_in));Executed by:
executed 32 times by 1 test: return (state->max_blocks_out && (state->p_send.blocks + out_blocks > state->max_blocks_out)) || (state->max_blocks_in && (state->p_read.blocks > state->max_blocks_in));Executed by:
| 0-32 | ||||||||||||||||||||||||
| 1077 | (
executed 32 times by 1 test: return (state->max_blocks_out && (state->p_send.blocks + out_blocks > state->max_blocks_out)) || (state->max_blocks_in && (state->p_read.blocks > state->max_blocks_in));Executed by:
| 0-32 | ||||||||||||||||||||||||
| 1078 | (state->max_blocks_in
executed 32 times by 1 test: return (state->max_blocks_out && (state->p_send.blocks + out_blocks > state->max_blocks_out)) || (state->max_blocks_in && (state->p_read.blocks > state->max_blocks_in));Executed by:
| 0-32 | ||||||||||||||||||||||||
| 1079 | (
executed 32 times by 1 test: return (state->max_blocks_out && (state->p_send.blocks + out_blocks > state->max_blocks_out)) || (state->max_blocks_in && (state->p_read.blocks > state->max_blocks_in));Executed by:
| 0-32 | ||||||||||||||||||||||||
| 1080 | } | - | ||||||||||||||||||||||||
| 1081 | - | |||||||||||||||||||||||||
| 1082 | - | |||||||||||||||||||||||||
| 1083 | - | |||||||||||||||||||||||||
| 1084 | - | |||||||||||||||||||||||||
| 1085 | - | |||||||||||||||||||||||||
| 1086 | - | |||||||||||||||||||||||||
| 1087 | static int | - | ||||||||||||||||||||||||
| 1088 | ssh_packet_enable_delayed_compress(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 1089 | { | - | ||||||||||||||||||||||||
| 1090 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 1091 | struct sshcomp *comp = | - | ||||||||||||||||||||||||
| 1092 | ((void *)0) | - | ||||||||||||||||||||||||
| 1093 | ; | - | ||||||||||||||||||||||||
| 1094 | int r, mode; | - | ||||||||||||||||||||||||
| 1095 | - | |||||||||||||||||||||||||
| 1096 | - | |||||||||||||||||||||||||
| 1097 | - | |||||||||||||||||||||||||
| 1098 | - | |||||||||||||||||||||||||
| 1099 | - | |||||||||||||||||||||||||
| 1100 | state->after_authentication = 1; | - | ||||||||||||||||||||||||
| 1101 | for (mode = 0; mode < MODE_MAX
| 32-64 | ||||||||||||||||||||||||
| 1102 | - | |||||||||||||||||||||||||
| 1103 | if (state->newkeys[mode] ==
| 0-64 | ||||||||||||||||||||||||
| 1104 | ((void *)0)
| 0-64 | ||||||||||||||||||||||||
| 1105 | ) | - | ||||||||||||||||||||||||
| 1106 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1107 | comp = &state->newkeys[mode]->comp; | - | ||||||||||||||||||||||||
| 1108 | if (comp
| 0-64 | ||||||||||||||||||||||||
| 1109 | if ((
| 0 | ||||||||||||||||||||||||
| 1110 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1111 | if (mode == MODE_OUT
| 0 | ||||||||||||||||||||||||
| 1112 | if ((
| 0 | ||||||||||||||||||||||||
| 1113 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1114 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1115 | if ((
| 0 | ||||||||||||||||||||||||
| 1116 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1117 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1118 | comp->enabled = 1; | - | ||||||||||||||||||||||||
| 1119 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1120 | } executed 64 times by 1 test: end of blockExecuted by:
| 64 | ||||||||||||||||||||||||
| 1121 | return executed 32 times by 1 test: 0;return 0;Executed by:
executed 32 times by 1 test: return 0;Executed by:
| 32 | ||||||||||||||||||||||||
| 1122 | } | - | ||||||||||||||||||||||||
| 1123 | - | |||||||||||||||||||||||||
| 1124 | - | |||||||||||||||||||||||||
| 1125 | int | - | ||||||||||||||||||||||||
| 1126 | ssh_packet_log_type(u_char type) | - | ||||||||||||||||||||||||
| 1127 | { | - | ||||||||||||||||||||||||
| 1128 | switch (type) { | - | ||||||||||||||||||||||||
| 1129 | case never executed: 94:case 94:never executed: case 94: | 0 | ||||||||||||||||||||||||
| 1130 | case never executed: 95:case 95:never executed: case 95: | 0 | ||||||||||||||||||||||||
| 1131 | case never executed: 93:case 93:never executed: case 93: | 0 | ||||||||||||||||||||||||
| 1132 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1133 | default executed 2080 times by 1 test: :default:Executed by:
executed 2080 times by 1 test: default:Executed by:
| 2080 | ||||||||||||||||||||||||
| 1134 | return executed 2080 times by 1 test: 1;return 1;Executed by:
executed 2080 times by 1 test: return 1;Executed by:
| 2080 | ||||||||||||||||||||||||
| 1135 | } | - | ||||||||||||||||||||||||
| 1136 | } | - | ||||||||||||||||||||||||
| 1137 | - | |||||||||||||||||||||||||
| 1138 | - | |||||||||||||||||||||||||
| 1139 | - | |||||||||||||||||||||||||
| 1140 | - | |||||||||||||||||||||||||
| 1141 | int | - | ||||||||||||||||||||||||
| 1142 | ssh_packet_send2_wrapped(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 1143 | { | - | ||||||||||||||||||||||||
| 1144 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 1145 | u_char type, *cp, macbuf[64]; | - | ||||||||||||||||||||||||
| 1146 | u_char tmp, padlen, pad = 0; | - | ||||||||||||||||||||||||
| 1147 | u_int authlen = 0, aadlen = 0; | - | ||||||||||||||||||||||||
| 1148 | u_int len; | - | ||||||||||||||||||||||||
| 1149 | struct sshenc *enc = | - | ||||||||||||||||||||||||
| 1150 | ((void *)0) | - | ||||||||||||||||||||||||
| 1151 | ; | - | ||||||||||||||||||||||||
| 1152 | struct sshmac *mac = | - | ||||||||||||||||||||||||
| 1153 | ((void *)0) | - | ||||||||||||||||||||||||
| 1154 | ; | - | ||||||||||||||||||||||||
| 1155 | struct sshcomp *comp = | - | ||||||||||||||||||||||||
| 1156 | ((void *)0) | - | ||||||||||||||||||||||||
| 1157 | ; | - | ||||||||||||||||||||||||
| 1158 | int r, block_size; | - | ||||||||||||||||||||||||
| 1159 | - | |||||||||||||||||||||||||
| 1160 | if (state->newkeys[MODE_OUT] !=
| 208-832 | ||||||||||||||||||||||||
| 1161 | ((void *)0)
| 208-832 | ||||||||||||||||||||||||
| 1162 | ) { | - | ||||||||||||||||||||||||
| 1163 | enc = &state->newkeys[MODE_OUT]->enc; | - | ||||||||||||||||||||||||
| 1164 | mac = &state->newkeys[MODE_OUT]->mac; | - | ||||||||||||||||||||||||
| 1165 | comp = &state->newkeys[MODE_OUT]->comp; | - | ||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||
| 1167 | if ((
| 0-832 | ||||||||||||||||||||||||
| 1168 | mac = executed 832 times by 1 test: mac = ((void *)0) ;Executed by:
| 832 | ||||||||||||||||||||||||
| 1169 | ((void *)0) executed 832 times by 1 test: mac = ((void *)0) ;Executed by:
| 832 | ||||||||||||||||||||||||
| 1170 | ; executed 832 times by 1 test: mac = ((void *)0) ;Executed by:
| 832 | ||||||||||||||||||||||||
| 1171 | } executed 832 times by 1 test: end of blockExecuted by:
| 832 | ||||||||||||||||||||||||
| 1172 | block_size = enc
| 208-832 | ||||||||||||||||||||||||
| 1173 | aadlen = (mac
| 0-1040 | ||||||||||||||||||||||||
| 1174 | - | |||||||||||||||||||||||||
| 1175 | type = (sshbuf_ptr(state->outgoing_packet))[5]; | - | ||||||||||||||||||||||||
| 1176 | if (ssh_packet_log_type(type)
| 0-1040 | ||||||||||||||||||||||||
| 1177 | debug3("send packet: type %u", type); executed 1040 times by 1 test: debug3("send packet: type %u", type);Executed by:
| 1040 | ||||||||||||||||||||||||
| 1178 | - | |||||||||||||||||||||||||
| 1179 | - | |||||||||||||||||||||||||
| 1180 | - | |||||||||||||||||||||||||
| 1181 | - | |||||||||||||||||||||||||
| 1182 | - | |||||||||||||||||||||||||
| 1183 | if (comp
| 0-832 | ||||||||||||||||||||||||
| 1184 | len = sshbuf_len(state->outgoing_packet); | - | ||||||||||||||||||||||||
| 1185 | - | |||||||||||||||||||||||||
| 1186 | if ((
| 0 | ||||||||||||||||||||||||
| 1187 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1188 | sshbuf_reset(state->compression_buffer); | - | ||||||||||||||||||||||||
| 1189 | if ((
| 0 | ||||||||||||||||||||||||
| 1190 | state->compression_buffer)) != 0
| 0 | ||||||||||||||||||||||||
| 1191 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1192 | sshbuf_reset(state->outgoing_packet); | - | ||||||||||||||||||||||||
| 1193 | if ((
| 0 | ||||||||||||||||||||||||
| 1194 | "\0\0\0\0\0", 5)) != 0
| 0 | ||||||||||||||||||||||||
| 1195 | (
| 0 | ||||||||||||||||||||||||
| 1196 | state->compression_buffer)) != 0
| 0 | ||||||||||||||||||||||||
| 1197 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1198 | - | |||||||||||||||||||||||||
| 1199 | ; | - | ||||||||||||||||||||||||
| 1200 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1201 | - | |||||||||||||||||||||||||
| 1202 | - | |||||||||||||||||||||||||
| 1203 | len = sshbuf_len(state->outgoing_packet); | - | ||||||||||||||||||||||||
| 1204 | - | |||||||||||||||||||||||||
| 1205 | - | |||||||||||||||||||||||||
| 1206 | - | |||||||||||||||||||||||||
| 1207 | - | |||||||||||||||||||||||||
| 1208 | - | |||||||||||||||||||||||||
| 1209 | len -= aadlen; | - | ||||||||||||||||||||||||
| 1210 | padlen = block_size - (len % block_size); | - | ||||||||||||||||||||||||
| 1211 | if (padlen < 4
| 332-708 | ||||||||||||||||||||||||
| 1212 | padlen += block_size; executed 332 times by 1 test: padlen += block_size;Executed by:
| 332 | ||||||||||||||||||||||||
| 1213 | if (state->extra_pad
| 0-1040 | ||||||||||||||||||||||||
| 1214 | tmp = state->extra_pad; | - | ||||||||||||||||||||||||
| 1215 | state->extra_pad = | - | ||||||||||||||||||||||||
| 1216 | ((((state->extra_pad)+((block_size)-1))/(block_size))*(block_size)); | - | ||||||||||||||||||||||||
| 1217 | - | |||||||||||||||||||||||||
| 1218 | if (state->extra_pad < tmp
| 0 | ||||||||||||||||||||||||
| 1219 | return never executed: -10;return -10;never executed: return -10; | 0 | ||||||||||||||||||||||||
| 1220 | tmp = (len + padlen) % state->extra_pad; | - | ||||||||||||||||||||||||
| 1221 | - | |||||||||||||||||||||||||
| 1222 | if (tmp > state->extra_pad
| 0 | ||||||||||||||||||||||||
| 1223 | return never executed: -10;return -10;never executed: return -10; | 0 | ||||||||||||||||||||||||
| 1224 | pad = state->extra_pad - tmp; | - | ||||||||||||||||||||||||
| 1225 | - | |||||||||||||||||||||||||
| 1226 | ; | - | ||||||||||||||||||||||||
| 1227 | tmp = padlen; | - | ||||||||||||||||||||||||
| 1228 | padlen += pad; | - | ||||||||||||||||||||||||
| 1229 | - | |||||||||||||||||||||||||
| 1230 | if (padlen < tmp
| 0 | ||||||||||||||||||||||||
| 1231 | return never executed: -10;return -10;never executed: return -10; | 0 | ||||||||||||||||||||||||
| 1232 | state->extra_pad = 0; | - | ||||||||||||||||||||||||
| 1233 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1234 | if ((
| 0-1040 | ||||||||||||||||||||||||
| 1235 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1236 | if (enc
| 0-832 | ||||||||||||||||||||||||
| 1237 | - | |||||||||||||||||||||||||
| 1238 | arc4random_buf(cp, padlen); | - | ||||||||||||||||||||||||
| 1239 | } executed 832 times by 1 test: else {end of blockExecuted by:
| 832 | ||||||||||||||||||||||||
| 1240 | - | |||||||||||||||||||||||||
| 1241 | explicit_bzero(cp, padlen); | - | ||||||||||||||||||||||||
| 1242 | } executed 208 times by 1 test: end of blockExecuted by:
| 208 | ||||||||||||||||||||||||
| 1243 | - | |||||||||||||||||||||||||
| 1244 | len = sshbuf_len(state->outgoing_packet); | - | ||||||||||||||||||||||||
| 1245 | cp = sshbuf_mutable_ptr(state->outgoing_packet); | - | ||||||||||||||||||||||||
| 1246 | if (cp ==
| 0-1040 | ||||||||||||||||||||||||
| 1247 | ((void *)0)
| 0-1040 | ||||||||||||||||||||||||
| 1248 | ) { | - | ||||||||||||||||||||||||
| 1249 | r = -1; | - | ||||||||||||||||||||||||
| 1250 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1251 | } | - | ||||||||||||||||||||||||
| 1252 | - | |||||||||||||||||||||||||
| 1253 | do { const u_int32_t __v = (len - 4); ((u_char *)(cp))[0] = (__v >> 24) & 0xff; ((u_char *)(cp))[1] = (__v >> 16) & 0xff; ((u_char *)(cp))[2] = (__v >> 8) & 0xff; ((u_char *)(cp))[3] = __v & 0xff; } while (0); | - | ||||||||||||||||||||||||
| 1254 | cp[4] = padlen; | - | ||||||||||||||||||||||||
| 1255 | - | |||||||||||||||||||||||||
| 1256 | ; | - | ||||||||||||||||||||||||
| 1257 | - | |||||||||||||||||||||||||
| 1258 | - | |||||||||||||||||||||||||
| 1259 | if (mac
| 0-1040 | ||||||||||||||||||||||||
| 1260 | if ((
| 0 | ||||||||||||||||||||||||
| 1261 | sshbuf_ptr(state->outgoing_packet), len,
| 0 | ||||||||||||||||||||||||
| 1262 | macbuf, sizeof(macbuf))) != 0
| 0 | ||||||||||||||||||||||||
| 1263 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1264 | ; | - | ||||||||||||||||||||||||
| 1265 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1266 | - | |||||||||||||||||||||||||
| 1267 | if ((
| 0-1040 | ||||||||||||||||||||||||
| 1268 | sshbuf_len(state->outgoing_packet) + authlen, &cp)) != 0
| 0-1040 | ||||||||||||||||||||||||
| 1269 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1270 | if ((
| 0-1040 | ||||||||||||||||||||||||
| 1271 | sshbuf_ptr(state->outgoing_packet),
| 0-1040 | ||||||||||||||||||||||||
| 1272 | len - aadlen, aadlen, authlen)) != 0
| 0-1040 | ||||||||||||||||||||||||
| 1273 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1274 | - | |||||||||||||||||||||||||
| 1275 | if (mac
| 0-1040 | ||||||||||||||||||||||||
| 1276 | if (mac->etm
| 0 | ||||||||||||||||||||||||
| 1277 | - | |||||||||||||||||||||||||
| 1278 | if ((
| 0 | ||||||||||||||||||||||||
| 1279 | cp, len, macbuf, sizeof(macbuf))) != 0
| 0 | ||||||||||||||||||||||||
| 1280 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1281 | - | |||||||||||||||||||||||||
| 1282 | ; | - | ||||||||||||||||||||||||
| 1283 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1284 | if ((
| 0 | ||||||||||||||||||||||||
| 1285 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1286 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1287 | - | |||||||||||||||||||||||||
| 1288 | - | |||||||||||||||||||||||||
| 1289 | - | |||||||||||||||||||||||||
| 1290 | - | |||||||||||||||||||||||||
| 1291 | - | |||||||||||||||||||||||||
| 1292 | if (++
| 0-1040 | ||||||||||||||||||||||||
| 1293 | logit("outgoing seqnr wraps around"); never executed: logit("outgoing seqnr wraps around"); | 0 | ||||||||||||||||||||||||
| 1294 | if (++
| 0-1040 | ||||||||||||||||||||||||
| 1295 | if (!(ssh->compat & 0x00008000)
| 0 | ||||||||||||||||||||||||
| 1296 | return never executed: -39;return -39;never executed: return -39; | 0 | ||||||||||||||||||||||||
| 1297 | state->p_send.blocks += len / block_size; | - | ||||||||||||||||||||||||
| 1298 | state->p_send.bytes += len; | - | ||||||||||||||||||||||||
| 1299 | sshbuf_reset(state->outgoing_packet); | - | ||||||||||||||||||||||||
| 1300 | - | |||||||||||||||||||||||||
| 1301 | if (type == 21
| 320-720 | ||||||||||||||||||||||||
| 1302 | r = ssh_set_newkeys(ssh, MODE_OUT); executed 320 times by 1 test: r = ssh_set_newkeys(ssh, MODE_OUT);Executed by:
| 320 | ||||||||||||||||||||||||
| 1303 | else if (type == 52
| 0-720 | ||||||||||||||||||||||||
| 1304 | r = ssh_packet_enable_delayed_compress(ssh); never executed: r = ssh_packet_enable_delayed_compress(ssh); | 0 | ||||||||||||||||||||||||
| 1305 | else | - | ||||||||||||||||||||||||
| 1306 | r = 0; executed 720 times by 1 test: r = 0;Executed by:
| 720 | ||||||||||||||||||||||||
| 1307 | out: code before this statement executed 1040 times by 1 test: out:Executed by:
| 1040 | ||||||||||||||||||||||||
| 1308 | return executed 1040 times by 1 test: r;return r;Executed by:
executed 1040 times by 1 test: return r;Executed by:
| 1040 | ||||||||||||||||||||||||
| 1309 | } | - | ||||||||||||||||||||||||
| 1310 | - | |||||||||||||||||||||||||
| 1311 | - | |||||||||||||||||||||||||
| 1312 | static int | - | ||||||||||||||||||||||||
| 1313 | ssh_packet_type_is_kex(u_char type) | - | ||||||||||||||||||||||||
| 1314 | { | - | ||||||||||||||||||||||||
| 1315 | return executed 1824 times by 1 test: return type >= 1 && type <= 49 && type != 5 && type != 6 && type != 7;Executed by:
| 1824 | ||||||||||||||||||||||||
| 1316 | type >= 1
executed 1824 times by 1 test: return type >= 1 && type <= 49 && type != 5 && type != 6 && type != 7;Executed by:
| 0-1824 | ||||||||||||||||||||||||
| 1317 | type <= 49
executed 1824 times by 1 test: return type >= 1 && type <= 49 && type != 5 && type != 6 && type != 7;Executed by:
| 0-1824 | ||||||||||||||||||||||||
| 1318 | type != 5
executed 1824 times by 1 test: return type >= 1 && type <= 49 && type != 5 && type != 6 && type != 7;Executed by:
| 0-1824 | ||||||||||||||||||||||||
| 1319 | type != 6
executed 1824 times by 1 test: return type >= 1 && type <= 49 && type != 5 && type != 6 && type != 7;Executed by:
| 0-1824 | ||||||||||||||||||||||||
| 1320 | type != 7
executed 1824 times by 1 test: return type >= 1 && type <= 49 && type != 5 && type != 6 && type != 7;Executed by:
| 0-1824 | ||||||||||||||||||||||||
| 1321 | } | - | ||||||||||||||||||||||||
| 1322 | - | |||||||||||||||||||||||||
| 1323 | int | - | ||||||||||||||||||||||||
| 1324 | ssh_packet_send2(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 1325 | { | - | ||||||||||||||||||||||||
| 1326 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 1327 | struct packet *p; | - | ||||||||||||||||||||||||
| 1328 | u_char type; | - | ||||||||||||||||||||||||
| 1329 | int r, need_rekey; | - | ||||||||||||||||||||||||
| 1330 | - | |||||||||||||||||||||||||
| 1331 | if (sshbuf_len(state->outgoing_packet) < 6
| 0-1040 | ||||||||||||||||||||||||
| 1332 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 1333 | type = sshbuf_ptr(state->outgoing_packet)[5]; | - | ||||||||||||||||||||||||
| 1334 | need_rekey = !ssh_packet_type_is_kex(type)
| 0-1040 | ||||||||||||||||||||||||
| 1335 | ssh_packet_need_rekeying(ssh, sshbuf_len(state->outgoing_packet))
| 0 | ||||||||||||||||||||||||
| 1336 | - | |||||||||||||||||||||||||
| 1337 | - | |||||||||||||||||||||||||
| 1338 | - | |||||||||||||||||||||||||
| 1339 | - | |||||||||||||||||||||||||
| 1340 | - | |||||||||||||||||||||||||
| 1341 | if ((need_rekey
| 0-1040 | ||||||||||||||||||||||||
| 1342 | if (need_rekey
| 0 | ||||||||||||||||||||||||
| 1343 | debug3("%s: rekex triggered", __func__); never executed: debug3("%s: rekex triggered", __func__); | 0 | ||||||||||||||||||||||||
| 1344 | debug("enqueue packet: %u", type); | - | ||||||||||||||||||||||||
| 1345 | p = calloc(1, sizeof(*p)); | - | ||||||||||||||||||||||||
| 1346 | if (p ==
| 0 | ||||||||||||||||||||||||
| 1347 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1348 | ) | - | ||||||||||||||||||||||||
| 1349 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||
| 1350 | p->type = type; | - | ||||||||||||||||||||||||
| 1351 | p->payload = state->outgoing_packet; | - | ||||||||||||||||||||||||
| 1352 | do { (p)->next.tqe_next = | - | ||||||||||||||||||||||||
| 1353 | ((void *)0) | - | ||||||||||||||||||||||||
| 1354 | ; (p)->next.tqe_prev = (&state->outgoing)->tqh_last; *(&state->outgoing)->tqh_last = (p); (&state->outgoing)->tqh_last = &(p)->next.tqe_next; } while (0); | - | ||||||||||||||||||||||||
| 1355 | state->outgoing_packet = sshbuf_new(); | - | ||||||||||||||||||||||||
| 1356 | if (state->outgoing_packet ==
| 0 | ||||||||||||||||||||||||
| 1357 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1358 | ) | - | ||||||||||||||||||||||||
| 1359 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||
| 1360 | if (need_rekey
| 0 | ||||||||||||||||||||||||
| 1361 | - | |||||||||||||||||||||||||
| 1362 | - | |||||||||||||||||||||||||
| 1363 | - | |||||||||||||||||||||||||
| 1364 | - | |||||||||||||||||||||||||
| 1365 | - | |||||||||||||||||||||||||
| 1366 | return never executed: kex_start_rekex(ssh);return kex_start_rekex(ssh);never executed: return kex_start_rekex(ssh); | 0 | ||||||||||||||||||||||||
| 1367 | } | - | ||||||||||||||||||||||||
| 1368 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1369 | } | - | ||||||||||||||||||||||||
| 1370 | - | |||||||||||||||||||||||||
| 1371 | - | |||||||||||||||||||||||||
| 1372 | if (type == 20
| 320-720 | ||||||||||||||||||||||||
| 1373 | state->rekeying = 1; executed 320 times by 1 test: state->rekeying = 1;Executed by:
| 320 | ||||||||||||||||||||||||
| 1374 | - | |||||||||||||||||||||||||
| 1375 | if ((
| 0-1040 | ||||||||||||||||||||||||
| 1376 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1377 | - | |||||||||||||||||||||||||
| 1378 | - | |||||||||||||||||||||||||
| 1379 | if (type == 21
| 320-720 | ||||||||||||||||||||||||
| 1380 | state->rekeying = 0; | - | ||||||||||||||||||||||||
| 1381 | state->rekey_time = monotime(); | - | ||||||||||||||||||||||||
| 1382 | while ((
| 0-320 | ||||||||||||||||||||||||
| 1383 | type = p->type; | - | ||||||||||||||||||||||||
| 1384 | - | |||||||||||||||||||||||||
| 1385 | - | |||||||||||||||||||||||||
| 1386 | - | |||||||||||||||||||||||||
| 1387 | - | |||||||||||||||||||||||||
| 1388 | - | |||||||||||||||||||||||||
| 1389 | if (ssh_packet_need_rekeying(ssh,
| 0 | ||||||||||||||||||||||||
| 1390 | sshbuf_len(p->payload))
| 0 | ||||||||||||||||||||||||
| 1391 | debug3("%s: queued packet triggered rekex", | - | ||||||||||||||||||||||||
| 1392 | __func__); | - | ||||||||||||||||||||||||
| 1393 | return never executed: kex_start_rekex(ssh);return kex_start_rekex(ssh);never executed: return kex_start_rekex(ssh); | 0 | ||||||||||||||||||||||||
| 1394 | } | - | ||||||||||||||||||||||||
| 1395 | debug("dequeue packet: %u", type); | - | ||||||||||||||||||||||||
| 1396 | sshbuf_free(state->outgoing_packet); | - | ||||||||||||||||||||||||
| 1397 | state->outgoing_packet = p->payload; | - | ||||||||||||||||||||||||
| 1398 | do { if (((
| 0 | ||||||||||||||||||||||||
| 1399 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1400 | ) ( never executed: p)->next.tqe_next->next.tqe_prev = (p)->next.tqe_prev;(p)->next.tqe_next->next.tqe_prev = (p)->next.tqe_prev;never executed: else ((p)->next.tqe_next->next.tqe_prev = (p)->next.tqe_prev;never executed: &state->outgoing)->tqh_last = (p)->next.tqe_prev;(&state->outgoing)->tqh_last = (p)->next.tqe_prev;never executed: *(p)->next.tqe_prev = (p)->next.tqe_next; ; ; } while (0);(&state->outgoing)->tqh_last = (p)->next.tqe_prev; | 0 | ||||||||||||||||||||||||
| 1401 | memset(p, 0, sizeof(*p)); | - | ||||||||||||||||||||||||
| 1402 | free(p); | - | ||||||||||||||||||||||||
| 1403 | if ((
| 0 | ||||||||||||||||||||||||
| 1404 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1405 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1406 | } executed 320 times by 1 test: end of blockExecuted by:
| 320 | ||||||||||||||||||||||||
| 1407 | return executed 1040 times by 1 test: 0;return 0;Executed by:
executed 1040 times by 1 test: return 0;Executed by:
| 1040 | ||||||||||||||||||||||||
| 1408 | } | - | ||||||||||||||||||||||||
| 1409 | - | |||||||||||||||||||||||||
| 1410 | - | |||||||||||||||||||||||||
| 1411 | - | |||||||||||||||||||||||||
| 1412 | - | |||||||||||||||||||||||||
| 1413 | - | |||||||||||||||||||||||||
| 1414 | - | |||||||||||||||||||||||||
| 1415 | - | |||||||||||||||||||||||||
| 1416 | int | - | ||||||||||||||||||||||||
| 1417 | ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p) | - | ||||||||||||||||||||||||
| 1418 | { | - | ||||||||||||||||||||||||
| 1419 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 1420 | int len, r, ms_remain; | - | ||||||||||||||||||||||||
| 1421 | fd_set *setp; | - | ||||||||||||||||||||||||
| 1422 | char buf[8192]; | - | ||||||||||||||||||||||||
| 1423 | struct timeval timeout, start, *timeoutp = | - | ||||||||||||||||||||||||
| 1424 | ((void *)0) | - | ||||||||||||||||||||||||
| 1425 | ; | - | ||||||||||||||||||||||||
| 1426 | - | |||||||||||||||||||||||||
| 1427 | ; | - | ||||||||||||||||||||||||
| 1428 | - | |||||||||||||||||||||||||
| 1429 | setp = calloc( | - | ||||||||||||||||||||||||
| 1430 | ((( | - | ||||||||||||||||||||||||
| 1431 | state->connection_in + 1 | - | ||||||||||||||||||||||||
| 1432 | ) + (((8 * (int) sizeof (__fd_mask))) - 1)) / ((8 * (int) sizeof (__fd_mask)))) | - | ||||||||||||||||||||||||
| 1433 | - | |||||||||||||||||||||||||
| 1434 | , sizeof(fd_mask)); | - | ||||||||||||||||||||||||
| 1435 | if (setp ==
| 0 | ||||||||||||||||||||||||
| 1436 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1437 | ) | - | ||||||||||||||||||||||||
| 1438 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||
| 1439 | - | |||||||||||||||||||||||||
| 1440 | - | |||||||||||||||||||||||||
| 1441 | - | |||||||||||||||||||||||||
| 1442 | - | |||||||||||||||||||||||||
| 1443 | - | |||||||||||||||||||||||||
| 1444 | if ((
| 0 | ||||||||||||||||||||||||
| 1445 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1446 | - | |||||||||||||||||||||||||
| 1447 | - | |||||||||||||||||||||||||
| 1448 | for (;;) { | - | ||||||||||||||||||||||||
| 1449 | - | |||||||||||||||||||||||||
| 1450 | r = ssh_packet_read_poll_seqnr(ssh, typep, seqnr_p); | - | ||||||||||||||||||||||||
| 1451 | if (r != 0
| 0 | ||||||||||||||||||||||||
| 1452 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1453 | - | |||||||||||||||||||||||||
| 1454 | if (*
| 0 | ||||||||||||||||||||||||
| 1455 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1456 | - | |||||||||||||||||||||||||
| 1457 | - | |||||||||||||||||||||||||
| 1458 | - | |||||||||||||||||||||||||
| 1459 | - | |||||||||||||||||||||||||
| 1460 | memset(setp, 0, | - | ||||||||||||||||||||||||
| 1461 | ((( | - | ||||||||||||||||||||||||
| 1462 | state->connection_in + 1 | - | ||||||||||||||||||||||||
| 1463 | ) + (((8 * (int) sizeof (__fd_mask))) - 1)) / ((8 * (int) sizeof (__fd_mask)))) | - | ||||||||||||||||||||||||
| 1464 | - | |||||||||||||||||||||||||
| 1465 | * sizeof(fd_mask)); | - | ||||||||||||||||||||||||
| 1466 | kludge_FD_SET(state->connection_in, setp); | - | ||||||||||||||||||||||||
| 1467 | - | |||||||||||||||||||||||||
| 1468 | if (state->packet_timeout_ms > 0
| 0 | ||||||||||||||||||||||||
| 1469 | ms_remain = state->packet_timeout_ms; | - | ||||||||||||||||||||||||
| 1470 | timeoutp = &timeout; | - | ||||||||||||||||||||||||
| 1471 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1472 | - | |||||||||||||||||||||||||
| 1473 | for (;;) { | - | ||||||||||||||||||||||||
| 1474 | if (state->packet_timeout_ms != -1
| 0 | ||||||||||||||||||||||||
| 1475 | ms_to_timeval(&timeout, ms_remain); | - | ||||||||||||||||||||||||
| 1476 | monotime_tv(&start); | - | ||||||||||||||||||||||||
| 1477 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1478 | if ((
| 0 | ||||||||||||||||||||||||
| 1479 |
| 0 | ||||||||||||||||||||||||
| 1480 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1481 | ,
| 0 | ||||||||||||||||||||||||
| 1482 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1483 | , timeoutp)) >= 0
| 0 | ||||||||||||||||||||||||
| 1484 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1485 | if ( | - | ||||||||||||||||||||||||
| 1486 | (*
| 0 | ||||||||||||||||||||||||
| 1487 | !=
| 0 | ||||||||||||||||||||||||
| 1488 | 11
| 0 | ||||||||||||||||||||||||
| 1489 | && | - | ||||||||||||||||||||||||
| 1490 | (*
| 0 | ||||||||||||||||||||||||
| 1491 | !=
| 0 | ||||||||||||||||||||||||
| 1492 | 4
| 0 | ||||||||||||||||||||||||
| 1493 | && | - | ||||||||||||||||||||||||
| 1494 | - | |||||||||||||||||||||||||
| 1495 | (*
| 0 | ||||||||||||||||||||||||
| 1496 | !=
| 0 | ||||||||||||||||||||||||
| 1497 | 11
| 0 | ||||||||||||||||||||||||
| 1498 | ) { | - | ||||||||||||||||||||||||
| 1499 | r = -24; | - | ||||||||||||||||||||||||
| 1500 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1501 | } | - | ||||||||||||||||||||||||
| 1502 | if (state->packet_timeout_ms == -1
| 0 | ||||||||||||||||||||||||
| 1503 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1504 | ms_subtract_diff(&start, &ms_remain); | - | ||||||||||||||||||||||||
| 1505 | if (ms_remain <= 0
| 0 | ||||||||||||||||||||||||
| 1506 | r = 0; | - | ||||||||||||||||||||||||
| 1507 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1508 | } | - | ||||||||||||||||||||||||
| 1509 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1510 | if (r == 0
| 0 | ||||||||||||||||||||||||
| 1511 | r = -53; | - | ||||||||||||||||||||||||
| 1512 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1513 | } | - | ||||||||||||||||||||||||
| 1514 | - | |||||||||||||||||||||||||
| 1515 | len = read(state->connection_in, buf, sizeof(buf)); | - | ||||||||||||||||||||||||
| 1516 | if (len == 0
| 0 | ||||||||||||||||||||||||
| 1517 | r = -52; | - | ||||||||||||||||||||||||
| 1518 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1519 | } | - | ||||||||||||||||||||||||
| 1520 | if (len < 0
| 0 | ||||||||||||||||||||||||
| 1521 | r = -24; | - | ||||||||||||||||||||||||
| 1522 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1523 | } | - | ||||||||||||||||||||||||
| 1524 | - | |||||||||||||||||||||||||
| 1525 | - | |||||||||||||||||||||||||
| 1526 | if ((
| 0 | ||||||||||||||||||||||||
| 1527 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1528 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1529 | out: code before this statement never executed: out: | 0 | ||||||||||||||||||||||||
| 1530 | free(setp); | - | ||||||||||||||||||||||||
| 1531 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1532 | } | - | ||||||||||||||||||||||||
| 1533 | - | |||||||||||||||||||||||||
| 1534 | int | - | ||||||||||||||||||||||||
| 1535 | ssh_packet_read(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 1536 | { | - | ||||||||||||||||||||||||
| 1537 | u_char type; | - | ||||||||||||||||||||||||
| 1538 | int r; | - | ||||||||||||||||||||||||
| 1539 | - | |||||||||||||||||||||||||
| 1540 | if ((
| 0 | ||||||||||||||||||||||||
| 1541 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1542 | )) != 0
| 0 | ||||||||||||||||||||||||
| 1543 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||||||||||||||
| 1544 | return never executed: type;return type;never executed: return type; | 0 | ||||||||||||||||||||||||
| 1545 | } | - | ||||||||||||||||||||||||
| 1546 | - | |||||||||||||||||||||||||
| 1547 | - | |||||||||||||||||||||||||
| 1548 | - | |||||||||||||||||||||||||
| 1549 | - | |||||||||||||||||||||||||
| 1550 | - | |||||||||||||||||||||||||
| 1551 | - | |||||||||||||||||||||||||
| 1552 | int | - | ||||||||||||||||||||||||
| 1553 | ssh_packet_read_expect(struct ssh *ssh, u_int expected_type) | - | ||||||||||||||||||||||||
| 1554 | { | - | ||||||||||||||||||||||||
| 1555 | int r; | - | ||||||||||||||||||||||||
| 1556 | u_char type; | - | ||||||||||||||||||||||||
| 1557 | - | |||||||||||||||||||||||||
| 1558 | if ((
| 0 | ||||||||||||||||||||||||
| 1559 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1560 | )) != 0
| 0 | ||||||||||||||||||||||||
| 1561 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1562 | if (type != expected_type
| 0 | ||||||||||||||||||||||||
| 1563 | if ((
| 0 | ||||||||||||||||||||||||
| 1564 | "Protocol error: expected packet type %d, got %d",
| 0 | ||||||||||||||||||||||||
| 1565 | expected_type, type)) != 0
| 0 | ||||||||||||||||||||||||
| 1566 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1567 | return never executed: -55;return -55;never executed: return -55; | 0 | ||||||||||||||||||||||||
| 1568 | } | - | ||||||||||||||||||||||||
| 1569 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1570 | } | - | ||||||||||||||||||||||||
| 1571 | - | |||||||||||||||||||||||||
| 1572 | static int | - | ||||||||||||||||||||||||
| 1573 | ssh_packet_read_poll2_mux(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p) | - | ||||||||||||||||||||||||
| 1574 | { | - | ||||||||||||||||||||||||
| 1575 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 1576 | const u_char *cp; | - | ||||||||||||||||||||||||
| 1577 | size_t need; | - | ||||||||||||||||||||||||
| 1578 | int r; | - | ||||||||||||||||||||||||
| 1579 | - | |||||||||||||||||||||||||
| 1580 | if (ssh->kex
| 0 | ||||||||||||||||||||||||
| 1581 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 1582 | *typep = 0; | - | ||||||||||||||||||||||||
| 1583 | cp = sshbuf_ptr(state->input); | - | ||||||||||||||||||||||||
| 1584 | if (state->packlen == 0
| 0 | ||||||||||||||||||||||||
| 1585 | if (sshbuf_len(state->input) < 4 + 1
| 0 | ||||||||||||||||||||||||
| 1586 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1587 | state->packlen = (((u_int32_t)(((const u_char *)(cp))[0]) << 24) | ((u_int32_t)(((const u_char *)(cp))[1]) << 16) | ((u_int32_t)(((const u_char *)(cp))[2]) << 8) | (u_int32_t)(((const u_char *)(cp))[3])); | - | ||||||||||||||||||||||||
| 1588 | if (state->packlen < 4 + 1
| 0 | ||||||||||||||||||||||||
| 1589 | state->packlen > (256 * 1024)
| 0 | ||||||||||||||||||||||||
| 1590 | return never executed: -3;return -3;never executed: return -3; | 0 | ||||||||||||||||||||||||
| 1591 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1592 | need = state->packlen + 4; | - | ||||||||||||||||||||||||
| 1593 | if (sshbuf_len(state->input) < need
| 0 | ||||||||||||||||||||||||
| 1594 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1595 | sshbuf_reset(state->incoming_packet); | - | ||||||||||||||||||||||||
| 1596 | if ((
| 0 | ||||||||||||||||||||||||
| 1597 | state->packlen)) != 0
| 0 | ||||||||||||||||||||||||
| 1598 | (
| 0 | ||||||||||||||||||||||||
| 1599 | (
| 0 | ||||||||||||||||||||||||
| 1600 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1601 | )) != 0
| 0 | ||||||||||||||||||||||||
| 1602 | (
| 0 | ||||||||||||||||||||||||
| 1603 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1604 | if (ssh_packet_log_type(*typep)
| 0 | ||||||||||||||||||||||||
| 1605 | debug3("%s: type %u", __func__, *typep); never executed: debug3("%s: type %u", __func__, *typep); | 0 | ||||||||||||||||||||||||
| 1606 | - | |||||||||||||||||||||||||
| 1607 | - | |||||||||||||||||||||||||
| 1608 | state->packlen = 0; | - | ||||||||||||||||||||||||
| 1609 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1610 | } | - | ||||||||||||||||||||||||
| 1611 | - | |||||||||||||||||||||||||
| 1612 | int | - | ||||||||||||||||||||||||
| 1613 | ssh_packet_read_poll2(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p) | - | ||||||||||||||||||||||||
| 1614 | { | - | ||||||||||||||||||||||||
| 1615 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 1616 | u_int padlen, need; | - | ||||||||||||||||||||||||
| 1617 | u_char *cp; | - | ||||||||||||||||||||||||
| 1618 | u_int maclen, aadlen = 0, authlen = 0, block_size; | - | ||||||||||||||||||||||||
| 1619 | struct sshenc *enc = | - | ||||||||||||||||||||||||
| 1620 | ((void *)0) | - | ||||||||||||||||||||||||
| 1621 | ; | - | ||||||||||||||||||||||||
| 1622 | struct sshmac *mac = | - | ||||||||||||||||||||||||
| 1623 | ((void *)0) | - | ||||||||||||||||||||||||
| 1624 | ; | - | ||||||||||||||||||||||||
| 1625 | struct sshcomp *comp = | - | ||||||||||||||||||||||||
| 1626 | ((void *)0) | - | ||||||||||||||||||||||||
| 1627 | ; | - | ||||||||||||||||||||||||
| 1628 | int r; | - | ||||||||||||||||||||||||
| 1629 | - | |||||||||||||||||||||||||
| 1630 | if (state->mux
| 0-2992 | ||||||||||||||||||||||||
| 1631 | return never executed: ssh_packet_read_poll2_mux(ssh, typep, seqnr_p);return ssh_packet_read_poll2_mux(ssh, typep, seqnr_p);never executed: return ssh_packet_read_poll2_mux(ssh, typep, seqnr_p); | 0 | ||||||||||||||||||||||||
| 1632 | - | |||||||||||||||||||||||||
| 1633 | *typep = 0; | - | ||||||||||||||||||||||||
| 1634 | - | |||||||||||||||||||||||||
| 1635 | if (state->packet_discard
| 0-2992 | ||||||||||||||||||||||||
| 1636 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1637 | - | |||||||||||||||||||||||||
| 1638 | if (state->newkeys[MODE_IN] !=
| 432-2560 | ||||||||||||||||||||||||
| 1639 | ((void *)0)
| 432-2560 | ||||||||||||||||||||||||
| 1640 | ) { | - | ||||||||||||||||||||||||
| 1641 | enc = &state->newkeys[MODE_IN]->enc; | - | ||||||||||||||||||||||||
| 1642 | mac = &state->newkeys[MODE_IN]->mac; | - | ||||||||||||||||||||||||
| 1643 | comp = &state->newkeys[MODE_IN]->comp; | - | ||||||||||||||||||||||||
| 1644 | - | |||||||||||||||||||||||||
| 1645 | if ((
| 0-2560 | ||||||||||||||||||||||||
| 1646 | mac = executed 2560 times by 1 test: mac = ((void *)0) ;Executed by:
| 2560 | ||||||||||||||||||||||||
| 1647 | ((void *)0) executed 2560 times by 1 test: mac = ((void *)0) ;Executed by:
| 2560 | ||||||||||||||||||||||||
| 1648 | ; executed 2560 times by 1 test: mac = ((void *)0) ;Executed by:
| 2560 | ||||||||||||||||||||||||
| 1649 | } executed 2560 times by 1 test: end of blockExecuted by:
| 2560 | ||||||||||||||||||||||||
| 1650 | maclen = mac
| 0-2992 | ||||||||||||||||||||||||
| 1651 | block_size = enc
| 432-2560 | ||||||||||||||||||||||||
| 1652 | aadlen = (mac
| 0-2992 | ||||||||||||||||||||||||
| 1653 | - | |||||||||||||||||||||||||
| 1654 | if (aadlen
| 0-2560 | ||||||||||||||||||||||||
| 1655 | if (cipher_get_length(state->receive_context,
| 832-1728 | ||||||||||||||||||||||||
| 1656 | &state->packlen, state->p_read.seqnr,
| 832-1728 | ||||||||||||||||||||||||
| 1657 | sshbuf_ptr(state->input), sshbuf_len(state->input)) != 0
| 832-1728 | ||||||||||||||||||||||||
| 1658 | return executed 1728 times by 1 test: 0;return 0;Executed by:
executed 1728 times by 1 test: return 0;Executed by:
| 1728 | ||||||||||||||||||||||||
| 1659 | if (state->packlen < 1 + 4
| 0-832 | ||||||||||||||||||||||||
| 1660 | state->packlen > (256 * 1024)
| 0-832 | ||||||||||||||||||||||||
| 1661 | - | |||||||||||||||||||||||||
| 1662 | - | |||||||||||||||||||||||||
| 1663 | - | |||||||||||||||||||||||||
| 1664 | logit("Bad packet length %u.", state->packlen); | - | ||||||||||||||||||||||||
| 1665 | if ((
| 0 | ||||||||||||||||||||||||
| 1666 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1667 | return never executed: -54;return -54;never executed: return -54; | 0 | ||||||||||||||||||||||||
| 1668 | } | - | ||||||||||||||||||||||||
| 1669 | sshbuf_reset(state->incoming_packet); | - | ||||||||||||||||||||||||
| 1670 | } executed 832 times by 1 test: else if (state->packlen == 0end of blockExecuted by:
| 0-832 | ||||||||||||||||||||||||
| 1671 | - | |||||||||||||||||||||||||
| 1672 | - | |||||||||||||||||||||||||
| 1673 | - | |||||||||||||||||||||||||
| 1674 | - | |||||||||||||||||||||||||
| 1675 | if (sshbuf_len(state->input) < block_size
| 208-224 | ||||||||||||||||||||||||
| 1676 | return executed 224 times by 1 test: 0;return 0;Executed by:
executed 224 times by 1 test: return 0;Executed by:
| 224 | ||||||||||||||||||||||||
| 1677 | sshbuf_reset(state->incoming_packet); | - | ||||||||||||||||||||||||
| 1678 | if ((
| 0-208 | ||||||||||||||||||||||||
| 1679 | &cp)) != 0
| 0-208 | ||||||||||||||||||||||||
| 1680 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1681 | if ((
| 0-208 | ||||||||||||||||||||||||
| 1682 | state->p_send.seqnr, cp, sshbuf_ptr(state->input),
| 0-208 | ||||||||||||||||||||||||
| 1683 | block_size, 0, 0)) != 0
| 0-208 | ||||||||||||||||||||||||
| 1684 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1685 | state->packlen = (((u_int32_t)(((const u_char *)(sshbuf_ptr(state->incoming_packet)))[0]) << 24) | ((u_int32_t)(((const u_char *)(sshbuf_ptr(state->incoming_packet)))[1]) << 16) | ((u_int32_t)(((const u_char *)(sshbuf_ptr(state->incoming_packet)))[2]) << 8) | (u_int32_t)(((const u_char *)(sshbuf_ptr(state->incoming_packet)))[3])); | - | ||||||||||||||||||||||||
| 1686 | if (state->packlen < 1 + 4
| 0-208 | ||||||||||||||||||||||||
| 1687 | state->packlen > (256 * 1024)
| 0-208 | ||||||||||||||||||||||||
| 1688 | - | |||||||||||||||||||||||||
| 1689 | - | |||||||||||||||||||||||||
| 1690 | - | |||||||||||||||||||||||||
| 1691 | - | |||||||||||||||||||||||||
| 1692 | - | |||||||||||||||||||||||||
| 1693 | - | |||||||||||||||||||||||||
| 1694 | logit("Bad packet length %u.", state->packlen); | - | ||||||||||||||||||||||||
| 1695 | return never executed: ssh_packet_start_discard(ssh, enc, mac, 0,return ssh_packet_start_discard(ssh, enc, mac, 0, (256 * 1024));never executed: return ssh_packet_start_discard(ssh, enc, mac, 0, (256 * 1024)); | 0 | ||||||||||||||||||||||||
| 1696 | (256 * 1024)); never executed: return ssh_packet_start_discard(ssh, enc, mac, 0, (256 * 1024)); | 0 | ||||||||||||||||||||||||
| 1697 | } | - | ||||||||||||||||||||||||
| 1698 | if ((
| 0-208 | ||||||||||||||||||||||||
| 1699 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1700 | } executed 208 times by 1 test: end of blockExecuted by:
| 208 | ||||||||||||||||||||||||
| 1701 | ; | - | ||||||||||||||||||||||||
| 1702 | - | |||||||||||||||||||||||||
| 1703 | if (aadlen
| 208-832 | ||||||||||||||||||||||||
| 1704 | - | |||||||||||||||||||||||||
| 1705 | need = state->packlen; | - | ||||||||||||||||||||||||
| 1706 | } executed 832 times by 1 test: else {end of blockExecuted by:
| 832 | ||||||||||||||||||||||||
| 1707 | - | |||||||||||||||||||||||||
| 1708 | - | |||||||||||||||||||||||||
| 1709 | - | |||||||||||||||||||||||||
| 1710 | - | |||||||||||||||||||||||||
| 1711 | need = 4 + state->packlen - block_size; | - | ||||||||||||||||||||||||
| 1712 | } executed 208 times by 1 test: end of blockExecuted by:
| 208 | ||||||||||||||||||||||||
| 1713 | - | |||||||||||||||||||||||||
| 1714 | ; | - | ||||||||||||||||||||||||
| 1715 | if (need % block_size != 0
| 0-1040 | ||||||||||||||||||||||||
| 1716 | logit("padding error: need %d block %d mod %d", | - | ||||||||||||||||||||||||
| 1717 | need, block_size, need % block_size); | - | ||||||||||||||||||||||||
| 1718 | return never executed: ssh_packet_start_discard(ssh, enc, mac, 0,return ssh_packet_start_discard(ssh, enc, mac, 0, (256 * 1024) - block_size);never executed: return ssh_packet_start_discard(ssh, enc, mac, 0, (256 * 1024) - block_size); | 0 | ||||||||||||||||||||||||
| 1719 | (256 * 1024) - block_size); never executed: return ssh_packet_start_discard(ssh, enc, mac, 0, (256 * 1024) - block_size); | 0 | ||||||||||||||||||||||||
| 1720 | } | - | ||||||||||||||||||||||||
| 1721 | if (sshbuf_len(state->input) < aadlen + need + authlen + maclen
| 0-1040 | ||||||||||||||||||||||||
| 1722 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1723 | - | |||||||||||||||||||||||||
| 1724 | - | |||||||||||||||||||||||||
| 1725 | - | |||||||||||||||||||||||||
| 1726 | - | |||||||||||||||||||||||||
| 1727 | - | |||||||||||||||||||||||||
| 1728 | if (mac
| 0-1040 | ||||||||||||||||||||||||
| 1729 | if ((
| 0 | ||||||||||||||||||||||||
| 1730 | sshbuf_ptr(state->input), aadlen + need,
| 0 | ||||||||||||||||||||||||
| 1731 | sshbuf_ptr(state->input) + aadlen + need + authlen,
| 0 | ||||||||||||||||||||||||
| 1732 | maclen)) != 0
| 0 | ||||||||||||||||||||||||
| 1733 | if (r == -30
| 0 | ||||||||||||||||||||||||
| 1734 | logit("Corrupted MAC on input."); never executed: logit("Corrupted MAC on input."); | 0 | ||||||||||||||||||||||||
| 1735 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1736 | } | - | ||||||||||||||||||||||||
| 1737 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1738 | if ((
| 0-1040 | ||||||||||||||||||||||||
| 1739 | &cp)) != 0
| 0-1040 | ||||||||||||||||||||||||
| 1740 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1741 | if ((
| 0-1040 | ||||||||||||||||||||||||
| 1742 | sshbuf_ptr(state->input), need, aadlen, authlen)) != 0
| 0-1040 | ||||||||||||||||||||||||
| 1743 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1744 | if ((
| 0-1040 | ||||||||||||||||||||||||
| 1745 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1746 | if (mac
| 0-1040 | ||||||||||||||||||||||||
| 1747 | - | |||||||||||||||||||||||||
| 1748 | if (!mac->etm
| 0 | ||||||||||||||||||||||||
| 1749 | sshbuf_ptr(state->incoming_packet),
| 0 | ||||||||||||||||||||||||
| 1750 | sshbuf_len(state->incoming_packet),
| 0 | ||||||||||||||||||||||||
| 1751 | sshbuf_ptr(state->input), maclen)) != 0
| 0 | ||||||||||||||||||||||||
| 1752 | if (r != -30
| 0 | ||||||||||||||||||||||||
| 1753 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1754 | logit("Corrupted MAC on input."); | - | ||||||||||||||||||||||||
| 1755 | if (need + block_size > (256 * 1024)
| 0 | ||||||||||||||||||||||||
| 1756 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 1757 | return never executed: ssh_packet_start_discard(ssh, enc, mac,return ssh_packet_start_discard(ssh, enc, mac, sshbuf_len(state->incoming_packet), (256 * 1024) - need - block_size);never executed: return ssh_packet_start_discard(ssh, enc, mac, sshbuf_len(state->incoming_packet), (256 * 1024) - need - block_size); | 0 | ||||||||||||||||||||||||
| 1758 | sshbuf_len(state->incoming_packet), never executed: return ssh_packet_start_discard(ssh, enc, mac, sshbuf_len(state->incoming_packet), (256 * 1024) - need - block_size); | 0 | ||||||||||||||||||||||||
| 1759 | (256 * 1024) - need - block_size); never executed: return ssh_packet_start_discard(ssh, enc, mac, sshbuf_len(state->incoming_packet), (256 * 1024) - need - block_size); | 0 | ||||||||||||||||||||||||
| 1760 | } | - | ||||||||||||||||||||||||
| 1761 | - | |||||||||||||||||||||||||
| 1762 | ; | - | ||||||||||||||||||||||||
| 1763 | if ((
| 0 | ||||||||||||||||||||||||
| 1764 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1765 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1766 | if (seqnr_p !=
| 0-1040 | ||||||||||||||||||||||||
| 1767 | ((void *)0)
| 0-1040 | ||||||||||||||||||||||||
| 1768 | ) | - | ||||||||||||||||||||||||
| 1769 | * executed 1040 times by 1 test: seqnr_p = state->p_read.seqnr;*seqnr_p = state->p_read.seqnr;Executed by:
executed 1040 times by 1 test: *seqnr_p = state->p_read.seqnr;Executed by:
| 1040 | ||||||||||||||||||||||||
| 1770 | if (++
| 0-1040 | ||||||||||||||||||||||||
| 1771 | logit("incoming seqnr wraps around"); never executed: logit("incoming seqnr wraps around"); | 0 | ||||||||||||||||||||||||
| 1772 | if (++
| 0-1040 | ||||||||||||||||||||||||
| 1773 | if (!(ssh->compat & 0x00008000)
| 0 | ||||||||||||||||||||||||
| 1774 | return never executed: -39;return -39;never executed: return -39; | 0 | ||||||||||||||||||||||||
| 1775 | state->p_read.blocks += (state->packlen + 4) / block_size; | - | ||||||||||||||||||||||||
| 1776 | state->p_read.bytes += state->packlen + 4; | - | ||||||||||||||||||||||||
| 1777 | - | |||||||||||||||||||||||||
| 1778 | - | |||||||||||||||||||||||||
| 1779 | padlen = sshbuf_ptr(state->incoming_packet)[4]; | - | ||||||||||||||||||||||||
| 1780 | ; | - | ||||||||||||||||||||||||
| 1781 | if (padlen < 4
| 0-1040 | ||||||||||||||||||||||||
| 1782 | if ((
| 0 | ||||||||||||||||||||||||
| 1783 | "Corrupted padlen %d on input.", padlen)) != 0
| 0 | ||||||||||||||||||||||||
| 1784 | (
| 0 | ||||||||||||||||||||||||
| 1785 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1786 | return never executed: -54;return -54;never executed: return -54; | 0 | ||||||||||||||||||||||||
| 1787 | } | - | ||||||||||||||||||||||||
| 1788 | - | |||||||||||||||||||||||||
| 1789 | - | |||||||||||||||||||||||||
| 1790 | if ((
| 0-1040 | ||||||||||||||||||||||||
| 1791 | ((
| 0-1040 | ||||||||||||||||||||||||
| 1792 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1793 | - | |||||||||||||||||||||||||
| 1794 | - | |||||||||||||||||||||||||
| 1795 | ; | - | ||||||||||||||||||||||||
| 1796 | if (comp
| 0-832 | ||||||||||||||||||||||||
| 1797 | sshbuf_reset(state->compression_buffer); | - | ||||||||||||||||||||||||
| 1798 | if ((
| 0 | ||||||||||||||||||||||||
| 1799 | state->compression_buffer)) != 0
| 0 | ||||||||||||||||||||||||
| 1800 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1801 | sshbuf_reset(state->incoming_packet); | - | ||||||||||||||||||||||||
| 1802 | if ((
| 0 | ||||||||||||||||||||||||
| 1803 | state->compression_buffer)) != 0
| 0 | ||||||||||||||||||||||||
| 1804 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1805 | - | |||||||||||||||||||||||||
| 1806 | ; | - | ||||||||||||||||||||||||
| 1807 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1808 | - | |||||||||||||||||||||||||
| 1809 | - | |||||||||||||||||||||||||
| 1810 | - | |||||||||||||||||||||||||
| 1811 | - | |||||||||||||||||||||||||
| 1812 | if ((
| 0-1040 | ||||||||||||||||||||||||
| 1813 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 1814 | if (ssh_packet_log_type(*typep)
| 0-1040 | ||||||||||||||||||||||||
| 1815 | debug3("receive packet: type %u", *typep); executed 1040 times by 1 test: debug3("receive packet: type %u", *typep);Executed by:
| 1040 | ||||||||||||||||||||||||
| 1816 | if (*
| 0-1040 | ||||||||||||||||||||||||
| 1817 | if ((
| 0 | ||||||||||||||||||||||||
| 1818 | "Invalid ssh2 packet type: %d", *typep)) != 0
| 0 | ||||||||||||||||||||||||
| 1819 | (
| 0 | ||||||||||||||||||||||||
| 1820 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1821 | return never executed: -55;return -55;never executed: return -55; | 0 | ||||||||||||||||||||||||
| 1822 | } | - | ||||||||||||||||||||||||
| 1823 | if (state->hook_in !=
| 0-1040 | ||||||||||||||||||||||||
| 1824 | ((void *)0)
| 0-1040 | ||||||||||||||||||||||||
| 1825 | && | - | ||||||||||||||||||||||||
| 1826 | (
| 0 | ||||||||||||||||||||||||
| 1827 | state->hook_in_ctx)) != 0
| 0 | ||||||||||||||||||||||||
| 1828 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1829 | if (*
| 0-1040 | ||||||||||||||||||||||||
| 1830 | r = ssh_packet_enable_delayed_compress(ssh); never executed: r = ssh_packet_enable_delayed_compress(ssh); | 0 | ||||||||||||||||||||||||
| 1831 | else | - | ||||||||||||||||||||||||
| 1832 | r = 0; executed 1040 times by 1 test: r = 0;Executed by:
| 1040 | ||||||||||||||||||||||||
| 1833 | - | |||||||||||||||||||||||||
| 1834 | - | |||||||||||||||||||||||||
| 1835 | - | |||||||||||||||||||||||||
| 1836 | - | |||||||||||||||||||||||||
| 1837 | - | |||||||||||||||||||||||||
| 1838 | state->packlen = 0; | - | ||||||||||||||||||||||||
| 1839 | - | |||||||||||||||||||||||||
| 1840 | - | |||||||||||||||||||||||||
| 1841 | if (ssh_packet_need_rekeying(ssh, 0)
| 0-1040 | ||||||||||||||||||||||||
| 1842 | debug3("%s: rekex triggered", __func__); | - | ||||||||||||||||||||||||
| 1843 | if ((
| 0 | ||||||||||||||||||||||||
| 1844 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1845 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1846 | out: code before this statement executed 1040 times by 1 test: out:Executed by:
| 1040 | ||||||||||||||||||||||||
| 1847 | return executed 1040 times by 1 test: r;return r;Executed by:
executed 1040 times by 1 test: return r;Executed by:
| 1040 | ||||||||||||||||||||||||
| 1848 | } | - | ||||||||||||||||||||||||
| 1849 | - | |||||||||||||||||||||||||
| 1850 | int | - | ||||||||||||||||||||||||
| 1851 | ssh_packet_read_poll_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p) | - | ||||||||||||||||||||||||
| 1852 | { | - | ||||||||||||||||||||||||
| 1853 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 1854 | u_int reason, seqnr; | - | ||||||||||||||||||||||||
| 1855 | int r; | - | ||||||||||||||||||||||||
| 1856 | u_char *msg; | - | ||||||||||||||||||||||||
| 1857 | - | |||||||||||||||||||||||||
| 1858 | for (;;) { | - | ||||||||||||||||||||||||
| 1859 | msg = | - | ||||||||||||||||||||||||
| 1860 | ((void *)0) | - | ||||||||||||||||||||||||
| 1861 | ; | - | ||||||||||||||||||||||||
| 1862 | r = ssh_packet_read_poll2(ssh, typep, seqnr_p); | - | ||||||||||||||||||||||||
| 1863 | if (r != 0
| 0 | ||||||||||||||||||||||||
| 1864 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1865 | if (*
| 0 | ||||||||||||||||||||||||
| 1866 | state->keep_alive_timeouts = 0; | - | ||||||||||||||||||||||||
| 1867 | ; | - | ||||||||||||||||||||||||
| 1868 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1869 | switch (*typep) { | - | ||||||||||||||||||||||||
| 1870 | case never executed: 2:case 2:never executed: case 2: | 0 | ||||||||||||||||||||||||
| 1871 | debug3("Received SSH2_MSG_IGNORE"); | - | ||||||||||||||||||||||||
| 1872 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1873 | case never executed: 4:case 4:never executed: case 4: | 0 | ||||||||||||||||||||||||
| 1874 | if ((
| 0 | ||||||||||||||||||||||||
| 1875 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1876 | )) != 0
| 0 | ||||||||||||||||||||||||
| 1877 | (
| 0 | ||||||||||||||||||||||||
| 1878 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1879 | )) != 0
| 0 | ||||||||||||||||||||||||
| 1880 | (
| 0 | ||||||||||||||||||||||||
| 1881 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1882 | ,
| 0 | ||||||||||||||||||||||||
| 1883 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1884 | )) != 0
| 0 | ||||||||||||||||||||||||
| 1885 | free(msg); | - | ||||||||||||||||||||||||
| 1886 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1887 | } | - | ||||||||||||||||||||||||
| 1888 | debug("Remote: %.900s", msg); | - | ||||||||||||||||||||||||
| 1889 | free(msg); | - | ||||||||||||||||||||||||
| 1890 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1891 | case never executed: 1:case 1:never executed: case 1: | 0 | ||||||||||||||||||||||||
| 1892 | if ((
| 0 | ||||||||||||||||||||||||
| 1893 | (
| 0 | ||||||||||||||||||||||||
| 1894 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 1895 | )) != 0
| 0 | ||||||||||||||||||||||||
| 1896 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1897 | - | |||||||||||||||||||||||||
| 1898 | do_log2(ssh->state->server_side && | - | ||||||||||||||||||||||||
| 1899 | reason == 11 ? | - | ||||||||||||||||||||||||
| 1900 | SYSLOG_LEVEL_INFO : SYSLOG_LEVEL_ERROR, | - | ||||||||||||||||||||||||
| 1901 | "Received disconnect from %s port %d:" | - | ||||||||||||||||||||||||
| 1902 | "%u: %.400s", ssh_remote_ipaddr(ssh), | - | ||||||||||||||||||||||||
| 1903 | ssh_remote_port(ssh), reason, msg); | - | ||||||||||||||||||||||||
| 1904 | free(msg); | - | ||||||||||||||||||||||||
| 1905 | return never executed: -29;return -29;never executed: return -29; | 0 | ||||||||||||||||||||||||
| 1906 | case never executed: 3:case 3:never executed: case 3: | 0 | ||||||||||||||||||||||||
| 1907 | if ((
| 0 | ||||||||||||||||||||||||
| 1908 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1909 | debug("Received SSH2_MSG_UNIMPLEMENTED for %u", | - | ||||||||||||||||||||||||
| 1910 | seqnr); | - | ||||||||||||||||||||||||
| 1911 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1912 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 1913 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1914 | } | - | ||||||||||||||||||||||||
| 1915 | } | - | ||||||||||||||||||||||||
| 1916 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1917 | - | |||||||||||||||||||||||||
| 1918 | - | |||||||||||||||||||||||||
| 1919 | - | |||||||||||||||||||||||||
| 1920 | - | |||||||||||||||||||||||||
| 1921 | - | |||||||||||||||||||||||||
| 1922 | - | |||||||||||||||||||||||||
| 1923 | int | - | ||||||||||||||||||||||||
| 1924 | ssh_packet_process_incoming(struct ssh *ssh, const char *buf, u_int len) | - | ||||||||||||||||||||||||
| 1925 | { | - | ||||||||||||||||||||||||
| 1926 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 1927 | int r; | - | ||||||||||||||||||||||||
| 1928 | - | |||||||||||||||||||||||||
| 1929 | if (state->packet_discard
| 0 | ||||||||||||||||||||||||
| 1930 | state->keep_alive_timeouts = 0; | - | ||||||||||||||||||||||||
| 1931 | if (len >= state->packet_discard
| 0 | ||||||||||||||||||||||||
| 1932 | if ((
| 0 | ||||||||||||||||||||||||
| 1933 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1934 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1935 | state->packet_discard -= len; | - | ||||||||||||||||||||||||
| 1936 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1937 | } | - | ||||||||||||||||||||||||
| 1938 | if ((
| 0 | ||||||||||||||||||||||||
| 1939 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1940 | - | |||||||||||||||||||||||||
| 1941 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1942 | } | - | ||||||||||||||||||||||||
| 1943 | - | |||||||||||||||||||||||||
| 1944 | int | - | ||||||||||||||||||||||||
| 1945 | ssh_packet_remaining(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 1946 | { | - | ||||||||||||||||||||||||
| 1947 | return never executed: sshbuf_len(ssh->state->incoming_packet);return sshbuf_len(ssh->state->incoming_packet);never executed: return sshbuf_len(ssh->state->incoming_packet); | 0 | ||||||||||||||||||||||||
| 1948 | } | - | ||||||||||||||||||||||||
| 1949 | void | - | ||||||||||||||||||||||||
| 1950 | ssh_packet_send_debug(struct ssh *ssh, const char *fmt,...) | - | ||||||||||||||||||||||||
| 1951 | { | - | ||||||||||||||||||||||||
| 1952 | char buf[1024]; | - | ||||||||||||||||||||||||
| 1953 | va_list args; | - | ||||||||||||||||||||||||
| 1954 | int r; | - | ||||||||||||||||||||||||
| 1955 | - | |||||||||||||||||||||||||
| 1956 | if ((
| 0 | ||||||||||||||||||||||||
| 1957 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1958 | - | |||||||||||||||||||||||||
| 1959 | - | |||||||||||||||||||||||||
| 1960 | __builtin_va_start( | - | ||||||||||||||||||||||||
| 1961 | args | - | ||||||||||||||||||||||||
| 1962 | , | - | ||||||||||||||||||||||||
| 1963 | fmt | - | ||||||||||||||||||||||||
| 1964 | ) | - | ||||||||||||||||||||||||
| 1965 | ; | - | ||||||||||||||||||||||||
| 1966 | vsnprintf(buf, sizeof(buf), fmt, args); | - | ||||||||||||||||||||||||
| 1967 | - | |||||||||||||||||||||||||
| 1968 | __builtin_va_end( | - | ||||||||||||||||||||||||
| 1969 | args | - | ||||||||||||||||||||||||
| 1970 | ) | - | ||||||||||||||||||||||||
| 1971 | ; | - | ||||||||||||||||||||||||
| 1972 | - | |||||||||||||||||||||||||
| 1973 | debug3("sending debug message: %s", buf); | - | ||||||||||||||||||||||||
| 1974 | - | |||||||||||||||||||||||||
| 1975 | if ((
| 0 | ||||||||||||||||||||||||
| 1976 | (
| 0 | ||||||||||||||||||||||||
| 1977 | (
| 0 | ||||||||||||||||||||||||
| 1978 | (
| 0 | ||||||||||||||||||||||||
| 1979 | (
| 0 | ||||||||||||||||||||||||
| 1980 | (
| 0 | ||||||||||||||||||||||||
| 1981 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||||||||||||||
| 1982 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1983 | - | |||||||||||||||||||||||||
| 1984 | void | - | ||||||||||||||||||||||||
| 1985 | sshpkt_fmt_connection_id(struct ssh *ssh, char *s, size_t l) | - | ||||||||||||||||||||||||
| 1986 | { | - | ||||||||||||||||||||||||
| 1987 | snprintf(s, l, "%.200s%s%s port %d", | - | ||||||||||||||||||||||||
| 1988 | ssh->log_preamble ? ssh->log_preamble : "", | - | ||||||||||||||||||||||||
| 1989 | ssh->log_preamble ? " " : "", | - | ||||||||||||||||||||||||
| 1990 | ssh_remote_ipaddr(ssh), ssh_remote_port(ssh)); | - | ||||||||||||||||||||||||
| 1991 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1992 | - | |||||||||||||||||||||||||
| 1993 | - | |||||||||||||||||||||||||
| 1994 | - | |||||||||||||||||||||||||
| 1995 | - | |||||||||||||||||||||||||
| 1996 | void | - | ||||||||||||||||||||||||
| 1997 | sshpkt_fatal(struct ssh *ssh, const char *tag, int r) | - | ||||||||||||||||||||||||
| 1998 | { | - | ||||||||||||||||||||||||
| 1999 | char remote_id[512]; | - | ||||||||||||||||||||||||
| 2000 | - | |||||||||||||||||||||||||
| 2001 | sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id)); | - | ||||||||||||||||||||||||
| 2002 | - | |||||||||||||||||||||||||
| 2003 | switch (r) { | - | ||||||||||||||||||||||||
| 2004 | case never executed: -52:case -52:never executed: case -52: | 0 | ||||||||||||||||||||||||
| 2005 | ssh_packet_clear_keys(ssh); | - | ||||||||||||||||||||||||
| 2006 | logdie("Connection closed by %s", remote_id); | - | ||||||||||||||||||||||||
| 2007 | case never executed: -53:case -53:never executed: case -53:code before this statement never executed: case -53: | 0 | ||||||||||||||||||||||||
| 2008 | ssh_packet_clear_keys(ssh); | - | ||||||||||||||||||||||||
| 2009 | logdie("Connection %s %s timed out", | - | ||||||||||||||||||||||||
| 2010 | ssh->state->server_side ? "from" : "to", remote_id); | - | ||||||||||||||||||||||||
| 2011 | case never executed: -29:case -29:never executed: case -29:code before this statement never executed: case -29: | 0 | ||||||||||||||||||||||||
| 2012 | ssh_packet_clear_keys(ssh); | - | ||||||||||||||||||||||||
| 2013 | logdie("Disconnected from %s", remote_id); | - | ||||||||||||||||||||||||
| 2014 | case never executed: -24:case -24:never executed: case -24:code before this statement never executed: case -24: | 0 | ||||||||||||||||||||||||
| 2015 | if ( | - | ||||||||||||||||||||||||
| 2016 | (*
| 0 | ||||||||||||||||||||||||
| 2017 | ==
| 0 | ||||||||||||||||||||||||
| 2018 | 104
| 0 | ||||||||||||||||||||||||
| 2019 | ) { | - | ||||||||||||||||||||||||
| 2020 | ssh_packet_clear_keys(ssh); | - | ||||||||||||||||||||||||
| 2021 | logdie("Connection reset by %s", remote_id); | - | ||||||||||||||||||||||||
| 2022 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2023 | - | |||||||||||||||||||||||||
| 2024 | case never executed: -31:case -31:never executed: case -31:code before this statement never executed: case -31: | 0 | ||||||||||||||||||||||||
| 2025 | case never executed: -32:case -32:never executed: case -32: | 0 | ||||||||||||||||||||||||
| 2026 | case never executed: -33:case -33:never executed: case -33: | 0 | ||||||||||||||||||||||||
| 2027 | case never executed: -34:case -34:never executed: case -34: | 0 | ||||||||||||||||||||||||
| 2028 | case never executed: -35:case -35:never executed: case -35: | 0 | ||||||||||||||||||||||||
| 2029 | if (ssh
| 0 | ||||||||||||||||||||||||
| 2030 | ssh_packet_clear_keys(ssh); | - | ||||||||||||||||||||||||
| 2031 | logdie("Unable to negotiate with %s: %s. " | - | ||||||||||||||||||||||||
| 2032 | "Their offer: %s", remote_id, ssh_err(r), | - | ||||||||||||||||||||||||
| 2033 | ssh->kex->failed_choice); | - | ||||||||||||||||||||||||
| 2034 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2035 | - | |||||||||||||||||||||||||
| 2036 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||||||||
| 2037 | ssh_packet_clear_keys(ssh); | - | ||||||||||||||||||||||||
| 2038 | logdie("%s%sConnection %s %s: %s", | - | ||||||||||||||||||||||||
| 2039 | tag != | - | ||||||||||||||||||||||||
| 2040 | ((void *)0) | - | ||||||||||||||||||||||||
| 2041 | ? tag : "", tag != | - | ||||||||||||||||||||||||
| 2042 | ((void *)0) | - | ||||||||||||||||||||||||
| 2043 | ? ": " : "", | - | ||||||||||||||||||||||||
| 2044 | ssh->state->server_side ? "from" : "to", | - | ||||||||||||||||||||||||
| 2045 | remote_id, ssh_err(r)); | - | ||||||||||||||||||||||||
| 2046 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2047 | } | - | ||||||||||||||||||||||||
| 2048 | - | |||||||||||||||||||||||||
| 2049 | - | |||||||||||||||||||||||||
| 2050 | - | |||||||||||||||||||||||||
| 2051 | - | |||||||||||||||||||||||||
| 2052 | - | |||||||||||||||||||||||||
| 2053 | - | |||||||||||||||||||||||||
| 2054 | - | |||||||||||||||||||||||||
| 2055 | void | - | ||||||||||||||||||||||||
| 2056 | ssh_packet_disconnect(struct ssh *ssh, const char *fmt,...) | - | ||||||||||||||||||||||||
| 2057 | { | - | ||||||||||||||||||||||||
| 2058 | char buf[1024], remote_id[512]; | - | ||||||||||||||||||||||||
| 2059 | va_list args; | - | ||||||||||||||||||||||||
| 2060 | static int disconnecting = 0; | - | ||||||||||||||||||||||||
| 2061 | int r; | - | ||||||||||||||||||||||||
| 2062 | - | |||||||||||||||||||||||||
| 2063 | if (disconnecting
| 0 | ||||||||||||||||||||||||
| 2064 | fatal("packet_disconnect called recursively."); never executed: fatal("packet_disconnect called recursively."); | 0 | ||||||||||||||||||||||||
| 2065 | disconnecting = 1; | - | ||||||||||||||||||||||||
| 2066 | - | |||||||||||||||||||||||||
| 2067 | - | |||||||||||||||||||||||||
| 2068 | - | |||||||||||||||||||||||||
| 2069 | - | |||||||||||||||||||||||||
| 2070 | - | |||||||||||||||||||||||||
| 2071 | sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id)); | - | ||||||||||||||||||||||||
| 2072 | - | |||||||||||||||||||||||||
| 2073 | __builtin_va_start( | - | ||||||||||||||||||||||||
| 2074 | args | - | ||||||||||||||||||||||||
| 2075 | , | - | ||||||||||||||||||||||||
| 2076 | fmt | - | ||||||||||||||||||||||||
| 2077 | ) | - | ||||||||||||||||||||||||
| 2078 | ; | - | ||||||||||||||||||||||||
| 2079 | vsnprintf(buf, sizeof(buf), fmt, args); | - | ||||||||||||||||||||||||
| 2080 | - | |||||||||||||||||||||||||
| 2081 | __builtin_va_end( | - | ||||||||||||||||||||||||
| 2082 | args | - | ||||||||||||||||||||||||
| 2083 | ) | - | ||||||||||||||||||||||||
| 2084 | ; | - | ||||||||||||||||||||||||
| 2085 | - | |||||||||||||||||||||||||
| 2086 | - | |||||||||||||||||||||||||
| 2087 | logit("Disconnecting %s: %.100s", remote_id, buf); | - | ||||||||||||||||||||||||
| 2088 | - | |||||||||||||||||||||||||
| 2089 | - | |||||||||||||||||||||||||
| 2090 | - | |||||||||||||||||||||||||
| 2091 | - | |||||||||||||||||||||||||
| 2092 | - | |||||||||||||||||||||||||
| 2093 | if ((
| 0 | ||||||||||||||||||||||||
| 2094 | sshpkt_fatal(ssh, __func__, r); never executed: sshpkt_fatal(ssh, __func__, r); | 0 | ||||||||||||||||||||||||
| 2095 | - | |||||||||||||||||||||||||
| 2096 | if ((
| 0 | ||||||||||||||||||||||||
| 2097 | sshpkt_fatal(ssh, __func__, r); never executed: sshpkt_fatal(ssh, __func__, r); | 0 | ||||||||||||||||||||||||
| 2098 | - | |||||||||||||||||||||||||
| 2099 | - | |||||||||||||||||||||||||
| 2100 | ssh_packet_close(ssh); | - | ||||||||||||||||||||||||
| 2101 | cleanup_exit(255); | - | ||||||||||||||||||||||||
| 2102 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2103 | - | |||||||||||||||||||||||||
| 2104 | - | |||||||||||||||||||||||||
| 2105 | - | |||||||||||||||||||||||||
| 2106 | - | |||||||||||||||||||||||||
| 2107 | - | |||||||||||||||||||||||||
| 2108 | int | - | ||||||||||||||||||||||||
| 2109 | ssh_packet_write_poll(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2110 | { | - | ||||||||||||||||||||||||
| 2111 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 2112 | int len = sshbuf_len(state->output); | - | ||||||||||||||||||||||||
| 2113 | int r; | - | ||||||||||||||||||||||||
| 2114 | - | |||||||||||||||||||||||||
| 2115 | if (len > 0
| 0 | ||||||||||||||||||||||||
| 2116 | len = write(state->connection_out, | - | ||||||||||||||||||||||||
| 2117 | sshbuf_ptr(state->output), len); | - | ||||||||||||||||||||||||
| 2118 | if (len == -1
| 0 | ||||||||||||||||||||||||
| 2119 | if ( | - | ||||||||||||||||||||||||
| 2120 | (*
| 0 | ||||||||||||||||||||||||
| 2121 | ==
| 0 | ||||||||||||||||||||||||
| 2122 | 4
| 0 | ||||||||||||||||||||||||
| 2123 | || | - | ||||||||||||||||||||||||
| 2124 | (*
| 0 | ||||||||||||||||||||||||
| 2125 | ==
| 0 | ||||||||||||||||||||||||
| 2126 | 11
| 0 | ||||||||||||||||||||||||
| 2127 | || | - | ||||||||||||||||||||||||
| 2128 | - | |||||||||||||||||||||||||
| 2129 | (*
| 0 | ||||||||||||||||||||||||
| 2130 | ==
| 0 | ||||||||||||||||||||||||
| 2131 | 11
| 0 | ||||||||||||||||||||||||
| 2132 | ) | - | ||||||||||||||||||||||||
| 2133 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 2134 | return never executed: -24;return -24;never executed: return -24; | 0 | ||||||||||||||||||||||||
| 2135 | } | - | ||||||||||||||||||||||||
| 2136 | if (len == 0
| 0 | ||||||||||||||||||||||||
| 2137 | return never executed: -52;return -52;never executed: return -52; | 0 | ||||||||||||||||||||||||
| 2138 | if ((
| 0 | ||||||||||||||||||||||||
| 2139 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2140 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2141 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 2142 | } | - | ||||||||||||||||||||||||
| 2143 | - | |||||||||||||||||||||||||
| 2144 | - | |||||||||||||||||||||||||
| 2145 | - | |||||||||||||||||||||||||
| 2146 | - | |||||||||||||||||||||||||
| 2147 | - | |||||||||||||||||||||||||
| 2148 | int | - | ||||||||||||||||||||||||
| 2149 | ssh_packet_write_wait(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2150 | { | - | ||||||||||||||||||||||||
| 2151 | fd_set *setp; | - | ||||||||||||||||||||||||
| 2152 | int ret, r, ms_remain = 0; | - | ||||||||||||||||||||||||
| 2153 | struct timeval start, timeout, *timeoutp = | - | ||||||||||||||||||||||||
| 2154 | ((void *)0) | - | ||||||||||||||||||||||||
| 2155 | ; | - | ||||||||||||||||||||||||
| 2156 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 2157 | - | |||||||||||||||||||||||||
| 2158 | setp = calloc( | - | ||||||||||||||||||||||||
| 2159 | ((( | - | ||||||||||||||||||||||||
| 2160 | state->connection_out + 1 | - | ||||||||||||||||||||||||
| 2161 | ) + (((8 * (int) sizeof (__fd_mask))) - 1)) / ((8 * (int) sizeof (__fd_mask)))) | - | ||||||||||||||||||||||||
| 2162 | - | |||||||||||||||||||||||||
| 2163 | , sizeof(fd_mask)); | - | ||||||||||||||||||||||||
| 2164 | if (setp ==
| 0 | ||||||||||||||||||||||||
| 2165 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 2166 | ) | - | ||||||||||||||||||||||||
| 2167 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||
| 2168 | if ((
| 0 | ||||||||||||||||||||||||
| 2169 | free(setp); | - | ||||||||||||||||||||||||
| 2170 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2171 | } | - | ||||||||||||||||||||||||
| 2172 | while (ssh_packet_have_data_to_write(ssh)
| 0 | ||||||||||||||||||||||||
| 2173 | memset(setp, 0, | - | ||||||||||||||||||||||||
| 2174 | ((( | - | ||||||||||||||||||||||||
| 2175 | state->connection_out + 1 | - | ||||||||||||||||||||||||
| 2176 | ) + (((8 * (int) sizeof (__fd_mask))) - 1)) / ((8 * (int) sizeof (__fd_mask)))) | - | ||||||||||||||||||||||||
| 2177 | - | |||||||||||||||||||||||||
| 2178 | * sizeof(fd_mask)); | - | ||||||||||||||||||||||||
| 2179 | kludge_FD_SET(state->connection_out, setp); | - | ||||||||||||||||||||||||
| 2180 | - | |||||||||||||||||||||||||
| 2181 | if (state->packet_timeout_ms > 0
| 0 | ||||||||||||||||||||||||
| 2182 | ms_remain = state->packet_timeout_ms; | - | ||||||||||||||||||||||||
| 2183 | timeoutp = &timeout; | - | ||||||||||||||||||||||||
| 2184 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2185 | for (;;) { | - | ||||||||||||||||||||||||
| 2186 | if (state->packet_timeout_ms != -1
| 0 | ||||||||||||||||||||||||
| 2187 | ms_to_timeval(&timeout, ms_remain); | - | ||||||||||||||||||||||||
| 2188 | monotime_tv(&start); | - | ||||||||||||||||||||||||
| 2189 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2190 | if ((
| 0 | ||||||||||||||||||||||||
| 2191 |
| 0 | ||||||||||||||||||||||||
| 2192 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 2193 | , setp,
| 0 | ||||||||||||||||||||||||
| 2194 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 2195 | , timeoutp)) >= 0
| 0 | ||||||||||||||||||||||||
| 2196 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2197 | if ( | - | ||||||||||||||||||||||||
| 2198 | (*
| 0 | ||||||||||||||||||||||||
| 2199 | !=
| 0 | ||||||||||||||||||||||||
| 2200 | 11
| 0 | ||||||||||||||||||||||||
| 2201 | && | - | ||||||||||||||||||||||||
| 2202 | (*
| 0 | ||||||||||||||||||||||||
| 2203 | !=
| 0 | ||||||||||||||||||||||||
| 2204 | 4
| 0 | ||||||||||||||||||||||||
| 2205 | && | - | ||||||||||||||||||||||||
| 2206 | - | |||||||||||||||||||||||||
| 2207 | (*
| 0 | ||||||||||||||||||||||||
| 2208 | !=
| 0 | ||||||||||||||||||||||||
| 2209 | 11
| 0 | ||||||||||||||||||||||||
| 2210 | ) | - | ||||||||||||||||||||||||
| 2211 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2212 | if (state->packet_timeout_ms == -1
| 0 | ||||||||||||||||||||||||
| 2213 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2214 | ms_subtract_diff(&start, &ms_remain); | - | ||||||||||||||||||||||||
| 2215 | if (ms_remain <= 0
| 0 | ||||||||||||||||||||||||
| 2216 | ret = 0; | - | ||||||||||||||||||||||||
| 2217 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2218 | } | - | ||||||||||||||||||||||||
| 2219 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2220 | if (ret == 0
| 0 | ||||||||||||||||||||||||
| 2221 | free(setp); | - | ||||||||||||||||||||||||
| 2222 | return never executed: -53;return -53;never executed: return -53; | 0 | ||||||||||||||||||||||||
| 2223 | } | - | ||||||||||||||||||||||||
| 2224 | if ((
| 0 | ||||||||||||||||||||||||
| 2225 | free(setp); | - | ||||||||||||||||||||||||
| 2226 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2227 | } | - | ||||||||||||||||||||||||
| 2228 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2229 | free(setp); | - | ||||||||||||||||||||||||
| 2230 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 2231 | } | - | ||||||||||||||||||||||||
| 2232 | - | |||||||||||||||||||||||||
| 2233 | - | |||||||||||||||||||||||||
| 2234 | - | |||||||||||||||||||||||||
| 2235 | int | - | ||||||||||||||||||||||||
| 2236 | ssh_packet_have_data_to_write(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2237 | { | - | ||||||||||||||||||||||||
| 2238 | return never executed: sshbuf_len(ssh->state->output) != 0;return sshbuf_len(ssh->state->output) != 0;never executed: return sshbuf_len(ssh->state->output) != 0; | 0 | ||||||||||||||||||||||||
| 2239 | } | - | ||||||||||||||||||||||||
| 2240 | - | |||||||||||||||||||||||||
| 2241 | - | |||||||||||||||||||||||||
| 2242 | - | |||||||||||||||||||||||||
| 2243 | int | - | ||||||||||||||||||||||||
| 2244 | ssh_packet_not_very_much_data_to_write(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2245 | { | - | ||||||||||||||||||||||||
| 2246 | if (ssh->state->interactive_mode
| 0 | ||||||||||||||||||||||||
| 2247 | return never executed: sshbuf_len(ssh->state->output) < 16384;return sshbuf_len(ssh->state->output) < 16384;never executed: return sshbuf_len(ssh->state->output) < 16384; | 0 | ||||||||||||||||||||||||
| 2248 | else | - | ||||||||||||||||||||||||
| 2249 | return never executed: sshbuf_len(ssh->state->output) < 128 * 1024;return sshbuf_len(ssh->state->output) < 128 * 1024;never executed: return sshbuf_len(ssh->state->output) < 128 * 1024; | 0 | ||||||||||||||||||||||||
| 2250 | } | - | ||||||||||||||||||||||||
| 2251 | - | |||||||||||||||||||||||||
| 2252 | void | - | ||||||||||||||||||||||||
| 2253 | ssh_packet_set_tos(struct ssh *ssh, int tos) | - | ||||||||||||||||||||||||
| 2254 | { | - | ||||||||||||||||||||||||
| 2255 | - | |||||||||||||||||||||||||
| 2256 | if (!ssh_packet_connection_is_on_socket(ssh)
| 0 | ||||||||||||||||||||||||
| 2257 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2258 | switch (ssh_packet_connection_af(ssh)) { | - | ||||||||||||||||||||||||
| 2259 | - | |||||||||||||||||||||||||
| 2260 | case never executed: case 2 :never executed: case 2 : | 0 | ||||||||||||||||||||||||
| 2261 | 2 never executed: case 2 : | 0 | ||||||||||||||||||||||||
| 2262 | : never executed: case 2 : | 0 | ||||||||||||||||||||||||
| 2263 | debug3("%s: set IP_TOS 0x%02x", __func__, tos); | - | ||||||||||||||||||||||||
| 2264 | if (setsockopt(ssh->state->connection_in,
| 0 | ||||||||||||||||||||||||
| 2265 |
| 0 | ||||||||||||||||||||||||
| 2266 | IPPROTO_IP
| 0 | ||||||||||||||||||||||||
| 2267 | ,
| 0 | ||||||||||||||||||||||||
| 2268 | 1
| 0 | ||||||||||||||||||||||||
| 2269 | , &tos, sizeof(tos)) < 0
| 0 | ||||||||||||||||||||||||
| 2270 | error("setsockopt IP_TOS %d: %.100s:", never executed: error("setsockopt IP_TOS %d: %.100s:", tos, strerror( (*__errno_location ()) )); | 0 | ||||||||||||||||||||||||
| 2271 | tos, strerror( never executed: error("setsockopt IP_TOS %d: %.100s:", tos, strerror( (*__errno_location ()) )); | 0 | ||||||||||||||||||||||||
| 2272 | (*__errno_location ()) never executed: error("setsockopt IP_TOS %d: %.100s:", tos, strerror( (*__errno_location ()) )); | 0 | ||||||||||||||||||||||||
| 2273 | )); never executed: error("setsockopt IP_TOS %d: %.100s:", tos, strerror( (*__errno_location ()) )); | 0 | ||||||||||||||||||||||||
| 2274 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2275 | - | |||||||||||||||||||||||||
| 2276 | - | |||||||||||||||||||||||||
| 2277 | case never executed: case 10 :never executed: case 10 : | 0 | ||||||||||||||||||||||||
| 2278 | 10 never executed: case 10 : | 0 | ||||||||||||||||||||||||
| 2279 | : never executed: case 10 : | 0 | ||||||||||||||||||||||||
| 2280 | debug3("%s: set IPV6_TCLASS 0x%02x", __func__, tos); | - | ||||||||||||||||||||||||
| 2281 | if (setsockopt(ssh->state->connection_in,
| 0 | ||||||||||||||||||||||||
| 2282 |
| 0 | ||||||||||||||||||||||||
| 2283 | IPPROTO_IPV6
| 0 | ||||||||||||||||||||||||
| 2284 | ,
| 0 | ||||||||||||||||||||||||
| 2285 | 67
| 0 | ||||||||||||||||||||||||
| 2286 | , &tos, sizeof(tos)) < 0
| 0 | ||||||||||||||||||||||||
| 2287 | error("setsockopt IPV6_TCLASS %d: %.100s:", never executed: error("setsockopt IPV6_TCLASS %d: %.100s:", tos, strerror( (*__errno_location ()) )); | 0 | ||||||||||||||||||||||||
| 2288 | tos, strerror( never executed: error("setsockopt IPV6_TCLASS %d: %.100s:", tos, strerror( (*__errno_location ()) )); | 0 | ||||||||||||||||||||||||
| 2289 | (*__errno_location ()) never executed: error("setsockopt IPV6_TCLASS %d: %.100s:", tos, strerror( (*__errno_location ()) )); | 0 | ||||||||||||||||||||||||
| 2290 | )); never executed: error("setsockopt IPV6_TCLASS %d: %.100s:", tos, strerror( (*__errno_location ()) )); | 0 | ||||||||||||||||||||||||
| 2291 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2292 | - | |||||||||||||||||||||||||
| 2293 | } | - | ||||||||||||||||||||||||
| 2294 | - | |||||||||||||||||||||||||
| 2295 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2296 | - | |||||||||||||||||||||||||
| 2297 | - | |||||||||||||||||||||||||
| 2298 | - | |||||||||||||||||||||||||
| 2299 | void | - | ||||||||||||||||||||||||
| 2300 | ssh_packet_set_interactive(struct ssh *ssh, int interactive, int qos_interactive, int qos_bulk) | - | ||||||||||||||||||||||||
| 2301 | { | - | ||||||||||||||||||||||||
| 2302 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 2303 | - | |||||||||||||||||||||||||
| 2304 | if (state->set_interactive_called
| 0 | ||||||||||||||||||||||||
| 2305 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2306 | state->set_interactive_called = 1; | - | ||||||||||||||||||||||||
| 2307 | - | |||||||||||||||||||||||||
| 2308 | - | |||||||||||||||||||||||||
| 2309 | state->interactive_mode = interactive; | - | ||||||||||||||||||||||||
| 2310 | - | |||||||||||||||||||||||||
| 2311 | - | |||||||||||||||||||||||||
| 2312 | if (!ssh_packet_connection_is_on_socket(ssh)
| 0 | ||||||||||||||||||||||||
| 2313 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2314 | set_nodelay(state->connection_in); | - | ||||||||||||||||||||||||
| 2315 | ssh_packet_set_tos(ssh, interactive ? qos_interactive : | - | ||||||||||||||||||||||||
| 2316 | qos_bulk); | - | ||||||||||||||||||||||||
| 2317 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2318 | - | |||||||||||||||||||||||||
| 2319 | - | |||||||||||||||||||||||||
| 2320 | - | |||||||||||||||||||||||||
| 2321 | int | - | ||||||||||||||||||||||||
| 2322 | ssh_packet_is_interactive(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2323 | { | - | ||||||||||||||||||||||||
| 2324 | return never executed: ssh->state->interactive_mode;return ssh->state->interactive_mode;never executed: return ssh->state->interactive_mode; | 0 | ||||||||||||||||||||||||
| 2325 | } | - | ||||||||||||||||||||||||
| 2326 | - | |||||||||||||||||||||||||
| 2327 | int | - | ||||||||||||||||||||||||
| 2328 | ssh_packet_set_maxsize(struct ssh *ssh, u_int s) | - | ||||||||||||||||||||||||
| 2329 | { | - | ||||||||||||||||||||||||
| 2330 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 2331 | - | |||||||||||||||||||||||||
| 2332 | if (state->set_maxsize_called
| 0 | ||||||||||||||||||||||||
| 2333 | logit("packet_set_maxsize: called twice: old %d new %d", | - | ||||||||||||||||||||||||
| 2334 | state->max_packet_size, s); | - | ||||||||||||||||||||||||
| 2335 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 2336 | } | - | ||||||||||||||||||||||||
| 2337 | if (s < 4 * 1024
| 0 | ||||||||||||||||||||||||
| 2338 | logit("packet_set_maxsize: bad size %d", s); | - | ||||||||||||||||||||||||
| 2339 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 2340 | } | - | ||||||||||||||||||||||||
| 2341 | state->set_maxsize_called = 1; | - | ||||||||||||||||||||||||
| 2342 | debug("packet_set_maxsize: setting to %d", s); | - | ||||||||||||||||||||||||
| 2343 | state->max_packet_size = s; | - | ||||||||||||||||||||||||
| 2344 | return never executed: s;return s;never executed: return s; | 0 | ||||||||||||||||||||||||
| 2345 | } | - | ||||||||||||||||||||||||
| 2346 | - | |||||||||||||||||||||||||
| 2347 | int | - | ||||||||||||||||||||||||
| 2348 | ssh_packet_inc_alive_timeouts(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2349 | { | - | ||||||||||||||||||||||||
| 2350 | return never executed: ++ssh->state->keep_alive_timeouts;return ++ssh->state->keep_alive_timeouts;never executed: return ++ssh->state->keep_alive_timeouts; | 0 | ||||||||||||||||||||||||
| 2351 | } | - | ||||||||||||||||||||||||
| 2352 | - | |||||||||||||||||||||||||
| 2353 | void | - | ||||||||||||||||||||||||
| 2354 | ssh_packet_set_alive_timeouts(struct ssh *ssh, int ka) | - | ||||||||||||||||||||||||
| 2355 | { | - | ||||||||||||||||||||||||
| 2356 | ssh->state->keep_alive_timeouts = ka; | - | ||||||||||||||||||||||||
| 2357 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2358 | - | |||||||||||||||||||||||||
| 2359 | u_int | - | ||||||||||||||||||||||||
| 2360 | ssh_packet_get_maxsize(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2361 | { | - | ||||||||||||||||||||||||
| 2362 | return never executed: ssh->state->max_packet_size;return ssh->state->max_packet_size;never executed: return ssh->state->max_packet_size; | 0 | ||||||||||||||||||||||||
| 2363 | } | - | ||||||||||||||||||||||||
| 2364 | - | |||||||||||||||||||||||||
| 2365 | void | - | ||||||||||||||||||||||||
| 2366 | ssh_packet_set_rekey_limits(struct ssh *ssh, u_int64_t bytes, u_int32_t seconds) | - | ||||||||||||||||||||||||
| 2367 | { | - | ||||||||||||||||||||||||
| 2368 | debug3("rekey after %llu bytes, %u seconds", (unsigned long long)bytes, | - | ||||||||||||||||||||||||
| 2369 | (unsigned int)seconds); | - | ||||||||||||||||||||||||
| 2370 | ssh->state->rekey_limit = bytes; | - | ||||||||||||||||||||||||
| 2371 | ssh->state->rekey_interval = seconds; | - | ||||||||||||||||||||||||
| 2372 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2373 | - | |||||||||||||||||||||||||
| 2374 | time_t | - | ||||||||||||||||||||||||
| 2375 | ssh_packet_get_rekey_timeout(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2376 | { | - | ||||||||||||||||||||||||
| 2377 | time_t seconds; | - | ||||||||||||||||||||||||
| 2378 | - | |||||||||||||||||||||||||
| 2379 | seconds = ssh->state->rekey_time + ssh->state->rekey_interval - | - | ||||||||||||||||||||||||
| 2380 | monotime(); | - | ||||||||||||||||||||||||
| 2381 | return never executed: (seconds <= 0return (seconds <= 0 ? 1 : seconds);
never executed: return (seconds <= 0 ? 1 : seconds); | 0 | ||||||||||||||||||||||||
| 2382 | } | - | ||||||||||||||||||||||||
| 2383 | - | |||||||||||||||||||||||||
| 2384 | void | - | ||||||||||||||||||||||||
| 2385 | ssh_packet_set_server(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2386 | { | - | ||||||||||||||||||||||||
| 2387 | ssh->state->server_side = 1; | - | ||||||||||||||||||||||||
| 2388 | } executed 64 times by 1 test: end of blockExecuted by:
| 64 | ||||||||||||||||||||||||
| 2389 | - | |||||||||||||||||||||||||
| 2390 | void | - | ||||||||||||||||||||||||
| 2391 | ssh_packet_set_authenticated(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2392 | { | - | ||||||||||||||||||||||||
| 2393 | ssh->state->after_authentication = 1; | - | ||||||||||||||||||||||||
| 2394 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2395 | - | |||||||||||||||||||||||||
| 2396 | void * | - | ||||||||||||||||||||||||
| 2397 | ssh_packet_get_input(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2398 | { | - | ||||||||||||||||||||||||
| 2399 | return executed 976 times by 1 test: (void *)ssh->state->input;return (void *)ssh->state->input;Executed by:
executed 976 times by 1 test: return (void *)ssh->state->input;Executed by:
| 976 | ||||||||||||||||||||||||
| 2400 | } | - | ||||||||||||||||||||||||
| 2401 | - | |||||||||||||||||||||||||
| 2402 | void * | - | ||||||||||||||||||||||||
| 2403 | ssh_packet_get_output(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2404 | { | - | ||||||||||||||||||||||||
| 2405 | return executed 2992 times by 1 test: (void *)ssh->state->output;return (void *)ssh->state->output;Executed by:
executed 2992 times by 1 test: return (void *)ssh->state->output;Executed by:
| 2992 | ||||||||||||||||||||||||
| 2406 | } | - | ||||||||||||||||||||||||
| 2407 | - | |||||||||||||||||||||||||
| 2408 | - | |||||||||||||||||||||||||
| 2409 | static int | - | ||||||||||||||||||||||||
| 2410 | ssh_packet_set_postauth(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2411 | { | - | ||||||||||||||||||||||||
| 2412 | int r; | - | ||||||||||||||||||||||||
| 2413 | - | |||||||||||||||||||||||||
| 2414 | debug("%s: called", __func__); | - | ||||||||||||||||||||||||
| 2415 | - | |||||||||||||||||||||||||
| 2416 | ssh->state->after_authentication = 1; | - | ||||||||||||||||||||||||
| 2417 | ssh->state->rekeying = 0; | - | ||||||||||||||||||||||||
| 2418 | if ((
| 0-32 | ||||||||||||||||||||||||
| 2419 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2420 | return executed 32 times by 1 test: 0;return 0;Executed by:
executed 32 times by 1 test: return 0;Executed by:
| 32 | ||||||||||||||||||||||||
| 2421 | } | - | ||||||||||||||||||||||||
| 2422 | - | |||||||||||||||||||||||||
| 2423 | - | |||||||||||||||||||||||||
| 2424 | - | |||||||||||||||||||||||||
| 2425 | - | |||||||||||||||||||||||||
| 2426 | static int | - | ||||||||||||||||||||||||
| 2427 | kex_to_blob(struct sshbuf *m, struct kex *kex) | - | ||||||||||||||||||||||||
| 2428 | { | - | ||||||||||||||||||||||||
| 2429 | int r; | - | ||||||||||||||||||||||||
| 2430 | - | |||||||||||||||||||||||||
| 2431 | if ((
| 0-32 | ||||||||||||||||||||||||
| 2432 | kex->session_id_len)) != 0
| 0-32 | ||||||||||||||||||||||||
| 2433 | (
| 0-32 | ||||||||||||||||||||||||
| 2434 | (
| 0-32 | ||||||||||||||||||||||||
| 2435 | (
| 0-32 | ||||||||||||||||||||||||
| 2436 | (
| 0-32 | ||||||||||||||||||||||||
| 2437 | (
| 0-32 | ||||||||||||||||||||||||
| 2438 | (
| 0-32 | ||||||||||||||||||||||||
| 2439 | (
| 0-32 | ||||||||||||||||||||||||
| 2440 | (
| 0-32 | ||||||||||||||||||||||||
| 2441 | (
| 0-32 | ||||||||||||||||||||||||
| 2442 | (
| 0-32 | ||||||||||||||||||||||||
| 2443 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2444 | return executed 32 times by 1 test: 0;return 0;Executed by:
executed 32 times by 1 test: return 0;Executed by:
| 32 | ||||||||||||||||||||||||
| 2445 | } | - | ||||||||||||||||||||||||
| 2446 | - | |||||||||||||||||||||||||
| 2447 | - | |||||||||||||||||||||||||
| 2448 | static int | - | ||||||||||||||||||||||||
| 2449 | newkeys_to_blob(struct sshbuf *m, struct ssh *ssh, int mode) | - | ||||||||||||||||||||||||
| 2450 | { | - | ||||||||||||||||||||||||
| 2451 | struct sshbuf *b; | - | ||||||||||||||||||||||||
| 2452 | struct sshcipher_ctx *cc; | - | ||||||||||||||||||||||||
| 2453 | struct sshcomp *comp; | - | ||||||||||||||||||||||||
| 2454 | struct sshenc *enc; | - | ||||||||||||||||||||||||
| 2455 | struct sshmac *mac; | - | ||||||||||||||||||||||||
| 2456 | struct newkeys *newkey; | - | ||||||||||||||||||||||||
| 2457 | int r; | - | ||||||||||||||||||||||||
| 2458 | - | |||||||||||||||||||||||||
| 2459 | if ((
| 0-64 | ||||||||||||||||||||||||
| 2460 | ((void *)0)
| 0-64 | ||||||||||||||||||||||||
| 2461 | ) | - | ||||||||||||||||||||||||
| 2462 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 2463 | enc = &newkey->enc; | - | ||||||||||||||||||||||||
| 2464 | mac = &newkey->mac; | - | ||||||||||||||||||||||||
| 2465 | comp = &newkey->comp; | - | ||||||||||||||||||||||||
| 2466 | cc = (
| 32 | ||||||||||||||||||||||||
| 2467 | ssh->state->receive_context; | - | ||||||||||||||||||||||||
| 2468 | if ((
| 0-64 | ||||||||||||||||||||||||
| 2469 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2470 | if ((
| 0-64 | ||||||||||||||||||||||||
| 2471 | ((void *)0)
| 0-64 | ||||||||||||||||||||||||
| 2472 | ) | - | ||||||||||||||||||||||||
| 2473 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||
| 2474 | if ((
| 0-64 | ||||||||||||||||||||||||
| 2475 | (
| 0-64 | ||||||||||||||||||||||||
| 2476 | (
| 0-64 | ||||||||||||||||||||||||
| 2477 | (
| 0-64 | ||||||||||||||||||||||||
| 2478 | (
| 0-64 | ||||||||||||||||||||||||
| 2479 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2480 | if (cipher_authlen(enc->cipher) == 0
| 0-64 | ||||||||||||||||||||||||
| 2481 | if ((
| 0 | ||||||||||||||||||||||||
| 2482 | (
| 0 | ||||||||||||||||||||||||
| 2483 | (
| 0 | ||||||||||||||||||||||||
| 2484 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2485 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2486 | if ((
| 0-64 | ||||||||||||||||||||||||
| 2487 | (
| 0-64 | ||||||||||||||||||||||||
| 2488 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2489 | r = sshbuf_put_stringb(m, b); | - | ||||||||||||||||||||||||
| 2490 | out: code before this statement executed 64 times by 1 test: out:Executed by:
| 64 | ||||||||||||||||||||||||
| 2491 | sshbuf_free(b); | - | ||||||||||||||||||||||||
| 2492 | return executed 64 times by 1 test: r;return r;Executed by:
executed 64 times by 1 test: return r;Executed by:
| 64 | ||||||||||||||||||||||||
| 2493 | } | - | ||||||||||||||||||||||||
| 2494 | - | |||||||||||||||||||||||||
| 2495 | - | |||||||||||||||||||||||||
| 2496 | int | - | ||||||||||||||||||||||||
| 2497 | ssh_packet_get_state(struct ssh *ssh, struct sshbuf *m) | - | ||||||||||||||||||||||||
| 2498 | { | - | ||||||||||||||||||||||||
| 2499 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 2500 | int r; | - | ||||||||||||||||||||||||
| 2501 | - | |||||||||||||||||||||||||
| 2502 | if ((
| 0-32 | ||||||||||||||||||||||||
| 2503 | (
| 0-32 | ||||||||||||||||||||||||
| 2504 | (
| 0-32 | ||||||||||||||||||||||||
| 2505 | (
| 0-32 | ||||||||||||||||||||||||
| 2506 | (
| 0-32 | ||||||||||||||||||||||||
| 2507 | (
| 0-32 | ||||||||||||||||||||||||
| 2508 | (
| 0-32 | ||||||||||||||||||||||||
| 2509 | (
| 0-32 | ||||||||||||||||||||||||
| 2510 | (
| 0-32 | ||||||||||||||||||||||||
| 2511 | (
| 0-32 | ||||||||||||||||||||||||
| 2512 | (
| 0-32 | ||||||||||||||||||||||||
| 2513 | (
| 0-32 | ||||||||||||||||||||||||
| 2514 | (
| 0-32 | ||||||||||||||||||||||||
| 2515 | (
| 0-32 | ||||||||||||||||||||||||
| 2516 | (
| 0-32 | ||||||||||||||||||||||||
| 2517 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2518 | - | |||||||||||||||||||||||||
| 2519 | return executed 32 times by 1 test: 0;return 0;Executed by:
executed 32 times by 1 test: return 0;Executed by:
| 32 | ||||||||||||||||||||||||
| 2520 | } | - | ||||||||||||||||||||||||
| 2521 | - | |||||||||||||||||||||||||
| 2522 | - | |||||||||||||||||||||||||
| 2523 | static int | - | ||||||||||||||||||||||||
| 2524 | newkeys_from_blob(struct sshbuf *m, struct ssh *ssh, int mode) | - | ||||||||||||||||||||||||
| 2525 | { | - | ||||||||||||||||||||||||
| 2526 | struct sshbuf *b = | - | ||||||||||||||||||||||||
| 2527 | ((void *)0) | - | ||||||||||||||||||||||||
| 2528 | ; | - | ||||||||||||||||||||||||
| 2529 | struct sshcomp *comp; | - | ||||||||||||||||||||||||
| 2530 | struct sshenc *enc; | - | ||||||||||||||||||||||||
| 2531 | struct sshmac *mac; | - | ||||||||||||||||||||||||
| 2532 | struct newkeys *newkey = | - | ||||||||||||||||||||||||
| 2533 | ((void *)0) | - | ||||||||||||||||||||||||
| 2534 | ; | - | ||||||||||||||||||||||||
| 2535 | size_t keylen, ivlen, maclen; | - | ||||||||||||||||||||||||
| 2536 | int r; | - | ||||||||||||||||||||||||
| 2537 | - | |||||||||||||||||||||||||
| 2538 | if ((
| 0-64 | ||||||||||||||||||||||||
| 2539 | ((void *)0)
| 0-64 | ||||||||||||||||||||||||
| 2540 | ) { | - | ||||||||||||||||||||||||
| 2541 | r = -2; | - | ||||||||||||||||||||||||
| 2542 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2543 | } | - | ||||||||||||||||||||||||
| 2544 | if ((
| 0-64 | ||||||||||||||||||||||||
| 2545 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2546 | - | |||||||||||||||||||||||||
| 2547 | - | |||||||||||||||||||||||||
| 2548 | - | |||||||||||||||||||||||||
| 2549 | enc = &newkey->enc; | - | ||||||||||||||||||||||||
| 2550 | mac = &newkey->mac; | - | ||||||||||||||||||||||||
| 2551 | comp = &newkey->comp; | - | ||||||||||||||||||||||||
| 2552 | - | |||||||||||||||||||||||||
| 2553 | if ((
| 0-64 | ||||||||||||||||||||||||
| 2554 | ((void *)0)
| 0-64 | ||||||||||||||||||||||||
| 2555 | )) != 0
| 0-64 | ||||||||||||||||||||||||
| 2556 | (
| 0-64 | ||||||||||||||||||||||||
| 2557 | (
| 0-64 | ||||||||||||||||||||||||
| 2558 | (
| 0-64 | ||||||||||||||||||||||||
| 2559 | (
| 0-64 | ||||||||||||||||||||||||
| 2560 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2561 | if ((
| 0-64 | ||||||||||||||||||||||||
| 2562 | ((void *)0)
| 0-64 | ||||||||||||||||||||||||
| 2563 | ) { | - | ||||||||||||||||||||||||
| 2564 | r = -4; | - | ||||||||||||||||||||||||
| 2565 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2566 | } | - | ||||||||||||||||||||||||
| 2567 | if (cipher_authlen(enc->cipher) == 0
| 0-64 | ||||||||||||||||||||||||
| 2568 | if ((
| 0 | ||||||||||||||||||||||||
| 2569 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 2570 | )) != 0
| 0 | ||||||||||||||||||||||||
| 2571 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2572 | if ((
| 0 | ||||||||||||||||||||||||
| 2573 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2574 | if ((
| 0 | ||||||||||||||||||||||||
| 2575 | (
| 0 | ||||||||||||||||||||||||
| 2576 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2577 | if (maclen > mac->key_len
| 0 | ||||||||||||||||||||||||
| 2578 | r = -4; | - | ||||||||||||||||||||||||
| 2579 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2580 | } | - | ||||||||||||||||||||||||
| 2581 | mac->key_len = maclen; | - | ||||||||||||||||||||||||
| 2582 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2583 | if ((
| 0-64 | ||||||||||||||||||||||||
| 2584 | (
| 0-64 | ||||||||||||||||||||||||
| 2585 | ((void *)0)
| 0-64 | ||||||||||||||||||||||||
| 2586 | )) != 0
| 0-64 | ||||||||||||||||||||||||
| 2587 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2588 | if (sshbuf_len(b) != 0
| 0-64 | ||||||||||||||||||||||||
| 2589 | r = -4; | - | ||||||||||||||||||||||||
| 2590 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2591 | } | - | ||||||||||||||||||||||||
| 2592 | enc->key_len = keylen; | - | ||||||||||||||||||||||||
| 2593 | enc->iv_len = ivlen; | - | ||||||||||||||||||||||||
| 2594 | ssh->kex->newkeys[mode] = newkey; | - | ||||||||||||||||||||||||
| 2595 | newkey = | - | ||||||||||||||||||||||||
| 2596 | ((void *)0) | - | ||||||||||||||||||||||||
| 2597 | ; | - | ||||||||||||||||||||||||
| 2598 | r = 0; | - | ||||||||||||||||||||||||
| 2599 | out: code before this statement executed 64 times by 1 test: out:Executed by:
| 64 | ||||||||||||||||||||||||
| 2600 | free(newkey); | - | ||||||||||||||||||||||||
| 2601 | sshbuf_free(b); | - | ||||||||||||||||||||||||
| 2602 | return executed 64 times by 1 test: r;return r;Executed by:
executed 64 times by 1 test: return r;Executed by:
| 64 | ||||||||||||||||||||||||
| 2603 | } | - | ||||||||||||||||||||||||
| 2604 | - | |||||||||||||||||||||||||
| 2605 | - | |||||||||||||||||||||||||
| 2606 | static int | - | ||||||||||||||||||||||||
| 2607 | kex_from_blob(struct sshbuf *m, struct kex **kexp) | - | ||||||||||||||||||||||||
| 2608 | { | - | ||||||||||||||||||||||||
| 2609 | struct kex *kex; | - | ||||||||||||||||||||||||
| 2610 | int r; | - | ||||||||||||||||||||||||
| 2611 | - | |||||||||||||||||||||||||
| 2612 | if ((
| 0-32 | ||||||||||||||||||||||||
| 2613 | ((void *)0)
| 0-32 | ||||||||||||||||||||||||
| 2614 | || | - | ||||||||||||||||||||||||
| 2615 | (
| 0-32 | ||||||||||||||||||||||||
| 2616 | ((void *)0)
| 0-32 | ||||||||||||||||||||||||
| 2617 | || | - | ||||||||||||||||||||||||
| 2618 | (
| 0-32 | ||||||||||||||||||||||||
| 2619 | ((void *)0)
| 0-32 | ||||||||||||||||||||||||
| 2620 | ) { | - | ||||||||||||||||||||||||
| 2621 | r = -2; | - | ||||||||||||||||||||||||
| 2622 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2623 | } | - | ||||||||||||||||||||||||
| 2624 | if ((
| 0-32 | ||||||||||||||||||||||||
| 2625 | (
| 0-32 | ||||||||||||||||||||||||
| 2626 | (
| 0-32 | ||||||||||||||||||||||||
| 2627 | ((void *)0)
| 0-32 | ||||||||||||||||||||||||
| 2628 | )) != 0
| 0-32 | ||||||||||||||||||||||||
| 2629 | (
| 0-32 | ||||||||||||||||||||||||
| 2630 | (
| 0-32 | ||||||||||||||||||||||||
| 2631 | (
| 0-32 | ||||||||||||||||||||||||
| 2632 | (
| 0-32 | ||||||||||||||||||||||||
| 2633 | (
| 0-32 | ||||||||||||||||||||||||
| 2634 | (
| 0-32 | ||||||||||||||||||||||||
| 2635 | (
| 0-32 | ||||||||||||||||||||||||
| 2636 | ((void *)0)
| 0-32 | ||||||||||||||||||||||||
| 2637 | )) != 0
| 0-32 | ||||||||||||||||||||||||
| 2638 | (
| 0-32 | ||||||||||||||||||||||||
| 2639 | ((void *)0)
| 0-32 | ||||||||||||||||||||||||
| 2640 | )) != 0
| 0-32 | ||||||||||||||||||||||||
| 2641 | goto never executed: out;goto out;never executed: goto out; | 0 | ||||||||||||||||||||||||
| 2642 | kex->server = 1; | - | ||||||||||||||||||||||||
| 2643 | kex->done = 1; | - | ||||||||||||||||||||||||
| 2644 | r = 0; | - | ||||||||||||||||||||||||
| 2645 | out: code before this statement executed 32 times by 1 test: out:Executed by:
| 32 | ||||||||||||||||||||||||
| 2646 | if (r != 0
| 0-32 | ||||||||||||||||||||||||
| 2647 | ((void *)0)
| 0-32 | ||||||||||||||||||||||||
| 2648 | ) { | - | ||||||||||||||||||||||||
| 2649 | if (kex !=
| 0 | ||||||||||||||||||||||||
| 2650 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 2651 | ) { | - | ||||||||||||||||||||||||
| 2652 | sshbuf_free(kex->my); | - | ||||||||||||||||||||||||
| 2653 | sshbuf_free(kex->peer); | - | ||||||||||||||||||||||||
| 2654 | free(kex); | - | ||||||||||||||||||||||||
| 2655 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2656 | if (kexp !=
| 0 | ||||||||||||||||||||||||
| 2657 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 2658 | ) | - | ||||||||||||||||||||||||
| 2659 | * never executed: kexp = *kexp = ((void *)0) ;never executed: *kexp = ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 2660 | ((void *)0) never executed: *kexp = ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 2661 | ; never executed: *kexp = ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 2662 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2663 | *kexp = kex; | - | ||||||||||||||||||||||||
| 2664 | } executed 32 times by 1 test: end of blockExecuted by:
| 32 | ||||||||||||||||||||||||
| 2665 | return executed 32 times by 1 test: r;return r;Executed by:
executed 32 times by 1 test: return r;Executed by:
| 32 | ||||||||||||||||||||||||
| 2666 | } | - | ||||||||||||||||||||||||
| 2667 | - | |||||||||||||||||||||||||
| 2668 | - | |||||||||||||||||||||||||
| 2669 | - | |||||||||||||||||||||||||
| 2670 | - | |||||||||||||||||||||||||
| 2671 | - | |||||||||||||||||||||||||
| 2672 | int | - | ||||||||||||||||||||||||
| 2673 | ssh_packet_set_state(struct ssh *ssh, struct sshbuf *m) | - | ||||||||||||||||||||||||
| 2674 | { | - | ||||||||||||||||||||||||
| 2675 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 2676 | const u_char *input, *output; | - | ||||||||||||||||||||||||
| 2677 | size_t ilen, olen; | - | ||||||||||||||||||||||||
| 2678 | int r; | - | ||||||||||||||||||||||||
| 2679 | - | |||||||||||||||||||||||||
| 2680 | if ((
| 0-32 | ||||||||||||||||||||||||
| 2681 | (
| 0-32 | ||||||||||||||||||||||||
| 2682 | (
| 0-32 | ||||||||||||||||||||||||
| 2683 | (
| 0-32 | ||||||||||||||||||||||||
| 2684 | (
| 0-32 | ||||||||||||||||||||||||
| 2685 | (
| 0-32 | ||||||||||||||||||||||||
| 2686 | (
| 0-32 | ||||||||||||||||||||||||
| 2687 | (
| 0-32 | ||||||||||||||||||||||||
| 2688 | (
| 0-32 | ||||||||||||||||||||||||
| 2689 | (
| 0-32 | ||||||||||||||||||||||||
| 2690 | (
| 0-32 | ||||||||||||||||||||||||
| 2691 | (
| 0-32 | ||||||||||||||||||||||||
| 2692 | (
| 0-32 | ||||||||||||||||||||||||
| 2693 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2694 | - | |||||||||||||||||||||||||
| 2695 | - | |||||||||||||||||||||||||
| 2696 | - | |||||||||||||||||||||||||
| 2697 | - | |||||||||||||||||||||||||
| 2698 | state->rekey_time = monotime(); | - | ||||||||||||||||||||||||
| 2699 | - | |||||||||||||||||||||||||
| 2700 | if ((
| 0-32 | ||||||||||||||||||||||||
| 2701 | (
| 0-32 | ||||||||||||||||||||||||
| 2702 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2703 | - | |||||||||||||||||||||||||
| 2704 | if ((
| 0-32 | ||||||||||||||||||||||||
| 2705 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2706 | - | |||||||||||||||||||||||||
| 2707 | sshbuf_reset(state->input); | - | ||||||||||||||||||||||||
| 2708 | sshbuf_reset(state->output); | - | ||||||||||||||||||||||||
| 2709 | if ((
| 0-32 | ||||||||||||||||||||||||
| 2710 | (
| 0-32 | ||||||||||||||||||||||||
| 2711 | (
| 0-32 | ||||||||||||||||||||||||
| 2712 | (
| 0-32 | ||||||||||||||||||||||||
| 2713 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2714 | - | |||||||||||||||||||||||||
| 2715 | if (sshbuf_len(m)
| 0-32 | ||||||||||||||||||||||||
| 2716 | return never executed: -4;return -4;never executed: return -4; | 0 | ||||||||||||||||||||||||
| 2717 | debug3("%s: done", __func__); | - | ||||||||||||||||||||||||
| 2718 | return executed 32 times by 1 test: 0;return 0;Executed by:
executed 32 times by 1 test: return 0;Executed by:
| 32 | ||||||||||||||||||||||||
| 2719 | } | - | ||||||||||||||||||||||||
| 2720 | - | |||||||||||||||||||||||||
| 2721 | - | |||||||||||||||||||||||||
| 2722 | - | |||||||||||||||||||||||||
| 2723 | - | |||||||||||||||||||||||||
| 2724 | - | |||||||||||||||||||||||||
| 2725 | int | - | ||||||||||||||||||||||||
| 2726 | sshpkt_put(struct ssh *ssh, const void *v, size_t len) | - | ||||||||||||||||||||||||
| 2727 | { | - | ||||||||||||||||||||||||
| 2728 | return never executed: sshbuf_put(ssh->state->outgoing_packet, v, len);return sshbuf_put(ssh->state->outgoing_packet, v, len);never executed: return sshbuf_put(ssh->state->outgoing_packet, v, len); | 0 | ||||||||||||||||||||||||
| 2729 | } | - | ||||||||||||||||||||||||
| 2730 | - | |||||||||||||||||||||||||
| 2731 | int | - | ||||||||||||||||||||||||
| 2732 | sshpkt_putb(struct ssh *ssh, const struct sshbuf *b) | - | ||||||||||||||||||||||||
| 2733 | { | - | ||||||||||||||||||||||||
| 2734 | return executed 320 times by 1 test: sshbuf_putb(ssh->state->outgoing_packet, b);return sshbuf_putb(ssh->state->outgoing_packet, b);Executed by:
executed 320 times by 1 test: return sshbuf_putb(ssh->state->outgoing_packet, b);Executed by:
| 320 | ||||||||||||||||||||||||
| 2735 | } | - | ||||||||||||||||||||||||
| 2736 | - | |||||||||||||||||||||||||
| 2737 | int | - | ||||||||||||||||||||||||
| 2738 | sshpkt_put_u8(struct ssh *ssh, u_char val) | - | ||||||||||||||||||||||||
| 2739 | { | - | ||||||||||||||||||||||||
| 2740 | return never executed: sshbuf_put_u8(ssh->state->outgoing_packet, val);return sshbuf_put_u8(ssh->state->outgoing_packet, val);never executed: return sshbuf_put_u8(ssh->state->outgoing_packet, val); | 0 | ||||||||||||||||||||||||
| 2741 | } | - | ||||||||||||||||||||||||
| 2742 | - | |||||||||||||||||||||||||
| 2743 | int | - | ||||||||||||||||||||||||
| 2744 | sshpkt_put_u32(struct ssh *ssh, u_int32_t val) | - | ||||||||||||||||||||||||
| 2745 | { | - | ||||||||||||||||||||||||
| 2746 | return executed 120 times by 1 test: sshbuf_put_u32(ssh->state->outgoing_packet, val);return sshbuf_put_u32(ssh->state->outgoing_packet, val);Executed by:
executed 120 times by 1 test: return sshbuf_put_u32(ssh->state->outgoing_packet, val);Executed by:
| 120 | ||||||||||||||||||||||||
| 2747 | } | - | ||||||||||||||||||||||||
| 2748 | - | |||||||||||||||||||||||||
| 2749 | int | - | ||||||||||||||||||||||||
| 2750 | sshpkt_put_u64(struct ssh *ssh, u_int64_t val) | - | ||||||||||||||||||||||||
| 2751 | { | - | ||||||||||||||||||||||||
| 2752 | return never executed: sshbuf_put_u64(ssh->state->outgoing_packet, val);return sshbuf_put_u64(ssh->state->outgoing_packet, val);never executed: return sshbuf_put_u64(ssh->state->outgoing_packet, val); | 0 | ||||||||||||||||||||||||
| 2753 | } | - | ||||||||||||||||||||||||
| 2754 | - | |||||||||||||||||||||||||
| 2755 | int | - | ||||||||||||||||||||||||
| 2756 | sshpkt_put_string(struct ssh *ssh, const void *v, size_t len) | - | ||||||||||||||||||||||||
| 2757 | { | - | ||||||||||||||||||||||||
| 2758 | return executed 360 times by 1 test: sshbuf_put_string(ssh->state->outgoing_packet, v, len);return sshbuf_put_string(ssh->state->outgoing_packet, v, len);Executed by:
executed 360 times by 1 test: return sshbuf_put_string(ssh->state->outgoing_packet, v, len);Executed by:
| 360 | ||||||||||||||||||||||||
| 2759 | } | - | ||||||||||||||||||||||||
| 2760 | - | |||||||||||||||||||||||||
| 2761 | int | - | ||||||||||||||||||||||||
| 2762 | sshpkt_put_cstring(struct ssh *ssh, const void *v) | - | ||||||||||||||||||||||||
| 2763 | { | - | ||||||||||||||||||||||||
| 2764 | return never executed: sshbuf_put_cstring(ssh->state->outgoing_packet, v);return sshbuf_put_cstring(ssh->state->outgoing_packet, v);never executed: return sshbuf_put_cstring(ssh->state->outgoing_packet, v); | 0 | ||||||||||||||||||||||||
| 2765 | } | - | ||||||||||||||||||||||||
| 2766 | - | |||||||||||||||||||||||||
| 2767 | int | - | ||||||||||||||||||||||||
| 2768 | sshpkt_put_stringb(struct ssh *ssh, const struct sshbuf *v) | - | ||||||||||||||||||||||||
| 2769 | { | - | ||||||||||||||||||||||||
| 2770 | return never executed: sshbuf_put_stringb(ssh->state->outgoing_packet, v);return sshbuf_put_stringb(ssh->state->outgoing_packet, v);never executed: return sshbuf_put_stringb(ssh->state->outgoing_packet, v); | 0 | ||||||||||||||||||||||||
| 2771 | } | - | ||||||||||||||||||||||||
| 2772 | - | |||||||||||||||||||||||||
| 2773 | - | |||||||||||||||||||||||||
| 2774 | - | |||||||||||||||||||||||||
| 2775 | int | - | ||||||||||||||||||||||||
| 2776 | sshpkt_put_ec(struct ssh *ssh, const EC_POINT *v, const EC_GROUP *g) | - | ||||||||||||||||||||||||
| 2777 | { | - | ||||||||||||||||||||||||
| 2778 | return executed 120 times by 1 test: sshbuf_put_ec(ssh->state->outgoing_packet, v, g);return sshbuf_put_ec(ssh->state->outgoing_packet, v, g);Executed by:
executed 120 times by 1 test: return sshbuf_put_ec(ssh->state->outgoing_packet, v, g);Executed by:
| 120 | ||||||||||||||||||||||||
| 2779 | } | - | ||||||||||||||||||||||||
| 2780 | - | |||||||||||||||||||||||||
| 2781 | - | |||||||||||||||||||||||||
| 2782 | - | |||||||||||||||||||||||||
| 2783 | int | - | ||||||||||||||||||||||||
| 2784 | sshpkt_put_bignum2(struct ssh *ssh, const BIGNUM *v) | - | ||||||||||||||||||||||||
| 2785 | { | - | ||||||||||||||||||||||||
| 2786 | return executed 240 times by 1 test: sshbuf_put_bignum2(ssh->state->outgoing_packet, v);return sshbuf_put_bignum2(ssh->state->outgoing_packet, v);Executed by:
executed 240 times by 1 test: return sshbuf_put_bignum2(ssh->state->outgoing_packet, v);Executed by:
| 240 | ||||||||||||||||||||||||
| 2787 | } | - | ||||||||||||||||||||||||
| 2788 | - | |||||||||||||||||||||||||
| 2789 | - | |||||||||||||||||||||||||
| 2790 | - | |||||||||||||||||||||||||
| 2791 | - | |||||||||||||||||||||||||
| 2792 | int | - | ||||||||||||||||||||||||
| 2793 | sshpkt_get(struct ssh *ssh, void *valp, size_t len) | - | ||||||||||||||||||||||||
| 2794 | { | - | ||||||||||||||||||||||||
| 2795 | return never executed: sshbuf_get(ssh->state->incoming_packet, valp, len);return sshbuf_get(ssh->state->incoming_packet, valp, len);never executed: return sshbuf_get(ssh->state->incoming_packet, valp, len); | 0 | ||||||||||||||||||||||||
| 2796 | } | - | ||||||||||||||||||||||||
| 2797 | - | |||||||||||||||||||||||||
| 2798 | int | - | ||||||||||||||||||||||||
| 2799 | sshpkt_get_u8(struct ssh *ssh, u_char *valp) | - | ||||||||||||||||||||||||
| 2800 | { | - | ||||||||||||||||||||||||
| 2801 | return executed 5440 times by 1 test: sshbuf_get_u8(ssh->state->incoming_packet, valp);return sshbuf_get_u8(ssh->state->incoming_packet, valp);Executed by:
executed 5440 times by 1 test: return sshbuf_get_u8(ssh->state->incoming_packet, valp);Executed by:
| 5440 | ||||||||||||||||||||||||
| 2802 | } | - | ||||||||||||||||||||||||
| 2803 | - | |||||||||||||||||||||||||
| 2804 | int | - | ||||||||||||||||||||||||
| 2805 | sshpkt_get_u32(struct ssh *ssh, u_int32_t *valp) | - | ||||||||||||||||||||||||
| 2806 | { | - | ||||||||||||||||||||||||
| 2807 | return executed 440 times by 1 test: sshbuf_get_u32(ssh->state->incoming_packet, valp);return sshbuf_get_u32(ssh->state->incoming_packet, valp);Executed by:
executed 440 times by 1 test: return sshbuf_get_u32(ssh->state->incoming_packet, valp);Executed by:
| 440 | ||||||||||||||||||||||||
| 2808 | } | - | ||||||||||||||||||||||||
| 2809 | - | |||||||||||||||||||||||||
| 2810 | int | - | ||||||||||||||||||||||||
| 2811 | sshpkt_get_u64(struct ssh *ssh, u_int64_t *valp) | - | ||||||||||||||||||||||||
| 2812 | { | - | ||||||||||||||||||||||||
| 2813 | return never executed: sshbuf_get_u64(ssh->state->incoming_packet, valp);return sshbuf_get_u64(ssh->state->incoming_packet, valp);never executed: return sshbuf_get_u64(ssh->state->incoming_packet, valp); | 0 | ||||||||||||||||||||||||
| 2814 | } | - | ||||||||||||||||||||||||
| 2815 | - | |||||||||||||||||||||||||
| 2816 | int | - | ||||||||||||||||||||||||
| 2817 | sshpkt_get_string(struct ssh *ssh, u_char **valp, size_t *lenp) | - | ||||||||||||||||||||||||
| 2818 | { | - | ||||||||||||||||||||||||
| 2819 | return executed 3560 times by 1 test: sshbuf_get_string(ssh->state->incoming_packet, valp, lenp);return sshbuf_get_string(ssh->state->incoming_packet, valp, lenp);Executed by:
executed 3560 times by 1 test: return sshbuf_get_string(ssh->state->incoming_packet, valp, lenp);Executed by:
| 3560 | ||||||||||||||||||||||||
| 2820 | } | - | ||||||||||||||||||||||||
| 2821 | - | |||||||||||||||||||||||||
| 2822 | int | - | ||||||||||||||||||||||||
| 2823 | sshpkt_get_string_direct(struct ssh *ssh, const u_char **valp, size_t *lenp) | - | ||||||||||||||||||||||||
| 2824 | { | - | ||||||||||||||||||||||||
| 2825 | return never executed: sshbuf_get_string_direct(ssh->state->incoming_packet, valp, lenp);return sshbuf_get_string_direct(ssh->state->incoming_packet, valp, lenp);never executed: return sshbuf_get_string_direct(ssh->state->incoming_packet, valp, lenp); | 0 | ||||||||||||||||||||||||
| 2826 | } | - | ||||||||||||||||||||||||
| 2827 | - | |||||||||||||||||||||||||
| 2828 | int | - | ||||||||||||||||||||||||
| 2829 | sshpkt_peek_string_direct(struct ssh *ssh, const u_char **valp, size_t *lenp) | - | ||||||||||||||||||||||||
| 2830 | { | - | ||||||||||||||||||||||||
| 2831 | return never executed: sshbuf_peek_string_direct(ssh->state->incoming_packet, valp, lenp);return sshbuf_peek_string_direct(ssh->state->incoming_packet, valp, lenp);never executed: return sshbuf_peek_string_direct(ssh->state->incoming_packet, valp, lenp); | 0 | ||||||||||||||||||||||||
| 2832 | } | - | ||||||||||||||||||||||||
| 2833 | - | |||||||||||||||||||||||||
| 2834 | int | - | ||||||||||||||||||||||||
| 2835 | sshpkt_get_cstring(struct ssh *ssh, char **valp, size_t *lenp) | - | ||||||||||||||||||||||||
| 2836 | { | - | ||||||||||||||||||||||||
| 2837 | return never executed: sshbuf_get_cstring(ssh->state->incoming_packet, valp, lenp);return sshbuf_get_cstring(ssh->state->incoming_packet, valp, lenp);never executed: return sshbuf_get_cstring(ssh->state->incoming_packet, valp, lenp); | 0 | ||||||||||||||||||||||||
| 2838 | } | - | ||||||||||||||||||||||||
| 2839 | - | |||||||||||||||||||||||||
| 2840 | - | |||||||||||||||||||||||||
| 2841 | - | |||||||||||||||||||||||||
| 2842 | int | - | ||||||||||||||||||||||||
| 2843 | sshpkt_get_ec(struct ssh *ssh, EC_POINT *v, const EC_GROUP *g) | - | ||||||||||||||||||||||||
| 2844 | { | - | ||||||||||||||||||||||||
| 2845 | return executed 120 times by 1 test: sshbuf_get_ec(ssh->state->incoming_packet, v, g);return sshbuf_get_ec(ssh->state->incoming_packet, v, g);Executed by:
executed 120 times by 1 test: return sshbuf_get_ec(ssh->state->incoming_packet, v, g);Executed by:
| 120 | ||||||||||||||||||||||||
| 2846 | } | - | ||||||||||||||||||||||||
| 2847 | - | |||||||||||||||||||||||||
| 2848 | - | |||||||||||||||||||||||||
| 2849 | - | |||||||||||||||||||||||||
| 2850 | int | - | ||||||||||||||||||||||||
| 2851 | sshpkt_get_bignum2(struct ssh *ssh, BIGNUM *v) | - | ||||||||||||||||||||||||
| 2852 | { | - | ||||||||||||||||||||||||
| 2853 | return executed 240 times by 1 test: sshbuf_get_bignum2(ssh->state->incoming_packet, v);return sshbuf_get_bignum2(ssh->state->incoming_packet, v);Executed by:
executed 240 times by 1 test: return sshbuf_get_bignum2(ssh->state->incoming_packet, v);Executed by:
| 240 | ||||||||||||||||||||||||
| 2854 | } | - | ||||||||||||||||||||||||
| 2855 | - | |||||||||||||||||||||||||
| 2856 | - | |||||||||||||||||||||||||
| 2857 | int | - | ||||||||||||||||||||||||
| 2858 | sshpkt_get_end(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2859 | { | - | ||||||||||||||||||||||||
| 2860 | if (sshbuf_len(ssh->state->incoming_packet) > 0
| 0-1040 | ||||||||||||||||||||||||
| 2861 | return never executed: -23;return -23;never executed: return -23; | 0 | ||||||||||||||||||||||||
| 2862 | return executed 1040 times by 1 test: 0;return 0;Executed by:
executed 1040 times by 1 test: return 0;Executed by:
| 1040 | ||||||||||||||||||||||||
| 2863 | } | - | ||||||||||||||||||||||||
| 2864 | - | |||||||||||||||||||||||||
| 2865 | const u_char * | - | ||||||||||||||||||||||||
| 2866 | sshpkt_ptr(struct ssh *ssh, size_t *lenp) | - | ||||||||||||||||||||||||
| 2867 | { | - | ||||||||||||||||||||||||
| 2868 | if (lenp !=
| 0-320 | ||||||||||||||||||||||||
| 2869 | ((void *)0)
| 0-320 | ||||||||||||||||||||||||
| 2870 | ) | - | ||||||||||||||||||||||||
| 2871 | * executed 320 times by 1 test: lenp = sshbuf_len(ssh->state->incoming_packet);*lenp = sshbuf_len(ssh->state->incoming_packet);Executed by:
executed 320 times by 1 test: *lenp = sshbuf_len(ssh->state->incoming_packet);Executed by:
| 320 | ||||||||||||||||||||||||
| 2872 | return executed 320 times by 1 test: sshbuf_ptr(ssh->state->incoming_packet);return sshbuf_ptr(ssh->state->incoming_packet);Executed by:
executed 320 times by 1 test: return sshbuf_ptr(ssh->state->incoming_packet);Executed by:
| 320 | ||||||||||||||||||||||||
| 2873 | } | - | ||||||||||||||||||||||||
| 2874 | - | |||||||||||||||||||||||||
| 2875 | - | |||||||||||||||||||||||||
| 2876 | - | |||||||||||||||||||||||||
| 2877 | int | - | ||||||||||||||||||||||||
| 2878 | sshpkt_start(struct ssh *ssh, u_char type) | - | ||||||||||||||||||||||||
| 2879 | { | - | ||||||||||||||||||||||||
| 2880 | u_char buf[6]; | - | ||||||||||||||||||||||||
| 2881 | - | |||||||||||||||||||||||||
| 2882 | ; | - | ||||||||||||||||||||||||
| 2883 | memset(buf, 0, sizeof(buf)); | - | ||||||||||||||||||||||||
| 2884 | buf[sizeof(buf) - 1] = type; | - | ||||||||||||||||||||||||
| 2885 | sshbuf_reset(ssh->state->outgoing_packet); | - | ||||||||||||||||||||||||
| 2886 | return executed 1040 times by 1 test: sshbuf_put(ssh->state->outgoing_packet, buf, sizeof(buf));return sshbuf_put(ssh->state->outgoing_packet, buf, sizeof(buf));Executed by:
executed 1040 times by 1 test: return sshbuf_put(ssh->state->outgoing_packet, buf, sizeof(buf));Executed by:
| 1040 | ||||||||||||||||||||||||
| 2887 | } | - | ||||||||||||||||||||||||
| 2888 | - | |||||||||||||||||||||||||
| 2889 | static int | - | ||||||||||||||||||||||||
| 2890 | ssh_packet_send_mux(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2891 | { | - | ||||||||||||||||||||||||
| 2892 | struct session_state *state = ssh->state; | - | ||||||||||||||||||||||||
| 2893 | u_char type, *cp; | - | ||||||||||||||||||||||||
| 2894 | size_t len; | - | ||||||||||||||||||||||||
| 2895 | int r; | - | ||||||||||||||||||||||||
| 2896 | - | |||||||||||||||||||||||||
| 2897 | if (ssh->kex
| 0 | ||||||||||||||||||||||||
| 2898 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 2899 | len = sshbuf_len(state->outgoing_packet); | - | ||||||||||||||||||||||||
| 2900 | if (len < 6
| 0 | ||||||||||||||||||||||||
| 2901 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 2902 | cp = sshbuf_mutable_ptr(state->outgoing_packet); | - | ||||||||||||||||||||||||
| 2903 | type = cp[5]; | - | ||||||||||||||||||||||||
| 2904 | if (ssh_packet_log_type(type)
| 0 | ||||||||||||||||||||||||
| 2905 | debug3("%s: type %u", __func__, type); never executed: debug3("%s: type %u", __func__, type); | 0 | ||||||||||||||||||||||||
| 2906 | - | |||||||||||||||||||||||||
| 2907 | if (type >= 80
| 0 | ||||||||||||||||||||||||
| 2908 | type <= 127
| 0 | ||||||||||||||||||||||||
| 2909 | do { const u_int32_t __v = (len - 4); ((u_char *)(cp))[0] = (__v >> 24) & 0xff; ((u_char *)(cp))[1] = (__v >> 16) & 0xff; ((u_char *)(cp))[2] = (__v >> 8) & 0xff; ((u_char *)(cp))[3] = __v & 0xff; } while (0); | - | ||||||||||||||||||||||||
| 2910 | if ((
| 0 | ||||||||||||||||||||||||
| 2911 | state->outgoing_packet)) != 0
| 0 | ||||||||||||||||||||||||
| 2912 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2913 | - | |||||||||||||||||||||||||
| 2914 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2915 | sshbuf_reset(state->outgoing_packet); | - | ||||||||||||||||||||||||
| 2916 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 2917 | } | - | ||||||||||||||||||||||||
| 2918 | int | - | ||||||||||||||||||||||||
| 2919 | sshpkt_msg_ignore(struct ssh *ssh, u_int nbytes) | - | ||||||||||||||||||||||||
| 2920 | { | - | ||||||||||||||||||||||||
| 2921 | u_int32_t rnd = 0; | - | ||||||||||||||||||||||||
| 2922 | int r; | - | ||||||||||||||||||||||||
| 2923 | u_int i; | - | ||||||||||||||||||||||||
| 2924 | - | |||||||||||||||||||||||||
| 2925 | if ((
| 0 | ||||||||||||||||||||||||
| 2926 | (
| 0 | ||||||||||||||||||||||||
| 2927 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2928 | for (i = 0; i < nbytes
| 0 | ||||||||||||||||||||||||
| 2929 | if (i % 4 == 0
| 0 | ||||||||||||||||||||||||
| 2930 | rnd = arc4random(); never executed: rnd = arc4random(); | 0 | ||||||||||||||||||||||||
| 2931 | if ((
| 0 | ||||||||||||||||||||||||
| 2932 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2933 | rnd >>= 8; | - | ||||||||||||||||||||||||
| 2934 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2935 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 2936 | } | - | ||||||||||||||||||||||||
| 2937 | - | |||||||||||||||||||||||||
| 2938 | - | |||||||||||||||||||||||||
| 2939 | - | |||||||||||||||||||||||||
| 2940 | int | - | ||||||||||||||||||||||||
| 2941 | sshpkt_send(struct ssh *ssh) | - | ||||||||||||||||||||||||
| 2942 | { | - | ||||||||||||||||||||||||
| 2943 | if (ssh->state
| 0-1040 | ||||||||||||||||||||||||
| 2944 | return never executed: ssh_packet_send_mux(ssh);return ssh_packet_send_mux(ssh);never executed: return ssh_packet_send_mux(ssh); | 0 | ||||||||||||||||||||||||
| 2945 | return executed 1040 times by 1 test: ssh_packet_send2(ssh);return ssh_packet_send2(ssh);Executed by:
executed 1040 times by 1 test: return ssh_packet_send2(ssh);Executed by:
| 1040 | ||||||||||||||||||||||||
| 2946 | } | - | ||||||||||||||||||||||||
| 2947 | - | |||||||||||||||||||||||||
| 2948 | int | - | ||||||||||||||||||||||||
| 2949 | sshpkt_disconnect(struct ssh *ssh, const char *fmt,...) | - | ||||||||||||||||||||||||
| 2950 | { | - | ||||||||||||||||||||||||
| 2951 | char buf[1024]; | - | ||||||||||||||||||||||||
| 2952 | va_list args; | - | ||||||||||||||||||||||||
| 2953 | int r; | - | ||||||||||||||||||||||||
| 2954 | - | |||||||||||||||||||||||||
| 2955 | - | |||||||||||||||||||||||||
| 2956 | __builtin_va_start( | - | ||||||||||||||||||||||||
| 2957 | args | - | ||||||||||||||||||||||||
| 2958 | , | - | ||||||||||||||||||||||||
| 2959 | fmt | - | ||||||||||||||||||||||||
| 2960 | ) | - | ||||||||||||||||||||||||
| 2961 | ; | - | ||||||||||||||||||||||||
| 2962 | vsnprintf(buf, sizeof(buf), fmt, args); | - | ||||||||||||||||||||||||
| 2963 | - | |||||||||||||||||||||||||
| 2964 | __builtin_va_end( | - | ||||||||||||||||||||||||
| 2965 | args | - | ||||||||||||||||||||||||
| 2966 | ) | - | ||||||||||||||||||||||||
| 2967 | ; | - | ||||||||||||||||||||||||
| 2968 | - | |||||||||||||||||||||||||
| 2969 | if ((
| 0 | ||||||||||||||||||||||||
| 2970 | (
| 0 | ||||||||||||||||||||||||
| 2971 | (
| 0 | ||||||||||||||||||||||||
| 2972 | (
| 0 | ||||||||||||||||||||||||
| 2973 | (
| 0 | ||||||||||||||||||||||||
| 2974 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 2975 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 2976 | } | - | ||||||||||||||||||||||||
| 2977 | - | |||||||||||||||||||||||||
| 2978 | - | |||||||||||||||||||||||||
| 2979 | int | - | ||||||||||||||||||||||||
| 2980 | sshpkt_add_padding(struct ssh *ssh, u_char pad) | - | ||||||||||||||||||||||||
| 2981 | { | - | ||||||||||||||||||||||||
| 2982 | ssh->state->extra_pad = pad; | - | ||||||||||||||||||||||||
| 2983 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 2984 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |