| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssh/src/opacket.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | struct ssh *active_state, *backup_state; | - | ||||||||||||
| 8 | - | |||||||||||||
| 9 | - | |||||||||||||
| 10 | - | |||||||||||||
| 11 | void | - | ||||||||||||
| 12 | ssh_packet_start(struct ssh *ssh, u_char type) | - | ||||||||||||
| 13 | { | - | ||||||||||||
| 14 | int r; | - | ||||||||||||
| 15 | - | |||||||||||||
| 16 | if ((
| 0 | ||||||||||||
| 17 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 18 | } never executed: end of block | 0 | ||||||||||||
| 19 | - | |||||||||||||
| 20 | void | - | ||||||||||||
| 21 | ssh_packet_put_char(struct ssh *ssh, int value) | - | ||||||||||||
| 22 | { | - | ||||||||||||
| 23 | u_char ch = value; | - | ||||||||||||
| 24 | int r; | - | ||||||||||||
| 25 | - | |||||||||||||
| 26 | if ((
| 0 | ||||||||||||
| 27 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 28 | } never executed: end of block | 0 | ||||||||||||
| 29 | - | |||||||||||||
| 30 | void | - | ||||||||||||
| 31 | ssh_packet_put_int(struct ssh *ssh, u_int value) | - | ||||||||||||
| 32 | { | - | ||||||||||||
| 33 | int r; | - | ||||||||||||
| 34 | - | |||||||||||||
| 35 | if ((
| 0 | ||||||||||||
| 36 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 37 | } never executed: end of block | 0 | ||||||||||||
| 38 | - | |||||||||||||
| 39 | void | - | ||||||||||||
| 40 | ssh_packet_put_int64(struct ssh *ssh, u_int64_t value) | - | ||||||||||||
| 41 | { | - | ||||||||||||
| 42 | int r; | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | if ((
| 0 | ||||||||||||
| 45 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 46 | } never executed: end of block | 0 | ||||||||||||
| 47 | - | |||||||||||||
| 48 | void | - | ||||||||||||
| 49 | ssh_packet_put_string(struct ssh *ssh, const void *buf, u_int len) | - | ||||||||||||
| 50 | { | - | ||||||||||||
| 51 | int r; | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | if ((
| 0 | ||||||||||||
| 54 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 55 | } never executed: end of block | 0 | ||||||||||||
| 56 | - | |||||||||||||
| 57 | void | - | ||||||||||||
| 58 | ssh_packet_put_cstring(struct ssh *ssh, const char *str) | - | ||||||||||||
| 59 | { | - | ||||||||||||
| 60 | int r; | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | if ((
| 0 | ||||||||||||
| 63 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 64 | } never executed: end of block | 0 | ||||||||||||
| 65 | - | |||||||||||||
| 66 | void | - | ||||||||||||
| 67 | ssh_packet_put_raw(struct ssh *ssh, const void *buf, u_int len) | - | ||||||||||||
| 68 | { | - | ||||||||||||
| 69 | int r; | - | ||||||||||||
| 70 | - | |||||||||||||
| 71 | if ((
| 0 | ||||||||||||
| 72 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 73 | } never executed: end of block | 0 | ||||||||||||
| 74 | - | |||||||||||||
| 75 | - | |||||||||||||
| 76 | - | |||||||||||||
| 77 | void | - | ||||||||||||
| 78 | ssh_packet_put_bignum2(struct ssh *ssh, BIGNUM * value) | - | ||||||||||||
| 79 | { | - | ||||||||||||
| 80 | int r; | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | if ((
| 0 | ||||||||||||
| 83 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 84 | } never executed: end of block | 0 | ||||||||||||
| 85 | - | |||||||||||||
| 86 | - | |||||||||||||
| 87 | void | - | ||||||||||||
| 88 | ssh_packet_put_ecpoint(struct ssh *ssh, const EC_GROUP *curve, | - | ||||||||||||
| 89 | const EC_POINT *point) | - | ||||||||||||
| 90 | { | - | ||||||||||||
| 91 | int r; | - | ||||||||||||
| 92 | - | |||||||||||||
| 93 | if ((
| 0 | ||||||||||||
| 94 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 95 | } never executed: end of block | 0 | ||||||||||||
| 96 | - | |||||||||||||
| 97 | - | |||||||||||||
| 98 | - | |||||||||||||
| 99 | void | - | ||||||||||||
| 100 | ssh_packet_send(struct ssh *ssh) | - | ||||||||||||
| 101 | { | - | ||||||||||||
| 102 | int r; | - | ||||||||||||
| 103 | - | |||||||||||||
| 104 | if ((
| 0 | ||||||||||||
| 105 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 106 | } never executed: end of block | 0 | ||||||||||||
| 107 | - | |||||||||||||
| 108 | u_int | - | ||||||||||||
| 109 | ssh_packet_get_char(struct ssh *ssh) | - | ||||||||||||
| 110 | { | - | ||||||||||||
| 111 | u_char ch; | - | ||||||||||||
| 112 | int r; | - | ||||||||||||
| 113 | - | |||||||||||||
| 114 | if ((
| 0 | ||||||||||||
| 115 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 116 | return never executed: ch;return ch;never executed: return ch; | 0 | ||||||||||||
| 117 | } | - | ||||||||||||
| 118 | - | |||||||||||||
| 119 | u_int | - | ||||||||||||
| 120 | ssh_packet_get_int(struct ssh *ssh) | - | ||||||||||||
| 121 | { | - | ||||||||||||
| 122 | u_int val; | - | ||||||||||||
| 123 | int r; | - | ||||||||||||
| 124 | - | |||||||||||||
| 125 | if ((
| 0 | ||||||||||||
| 126 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 127 | return never executed: val;return val;never executed: return val; | 0 | ||||||||||||
| 128 | } | - | ||||||||||||
| 129 | - | |||||||||||||
| 130 | u_int64_t | - | ||||||||||||
| 131 | ssh_packet_get_int64(struct ssh *ssh) | - | ||||||||||||
| 132 | { | - | ||||||||||||
| 133 | u_int64_t val; | - | ||||||||||||
| 134 | int r; | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | if ((
| 0 | ||||||||||||
| 137 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 138 | return never executed: val;return val;never executed: return val; | 0 | ||||||||||||
| 139 | } | - | ||||||||||||
| 140 | - | |||||||||||||
| 141 | - | |||||||||||||
| 142 | - | |||||||||||||
| 143 | void | - | ||||||||||||
| 144 | ssh_packet_get_bignum2(struct ssh *ssh, BIGNUM * value) | - | ||||||||||||
| 145 | { | - | ||||||||||||
| 146 | int r; | - | ||||||||||||
| 147 | - | |||||||||||||
| 148 | if ((
| 0 | ||||||||||||
| 149 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 150 | } never executed: end of block | 0 | ||||||||||||
| 151 | - | |||||||||||||
| 152 | - | |||||||||||||
| 153 | void | - | ||||||||||||
| 154 | ssh_packet_get_ecpoint(struct ssh *ssh, const EC_GROUP *curve, EC_POINT *point) | - | ||||||||||||
| 155 | { | - | ||||||||||||
| 156 | int r; | - | ||||||||||||
| 157 | - | |||||||||||||
| 158 | if ((
| 0 | ||||||||||||
| 159 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 160 | } never executed: end of block | 0 | ||||||||||||
| 161 | - | |||||||||||||
| 162 | - | |||||||||||||
| 163 | - | |||||||||||||
| 164 | void * | - | ||||||||||||
| 165 | ssh_packet_get_string(struct ssh *ssh, u_int *length_ptr) | - | ||||||||||||
| 166 | { | - | ||||||||||||
| 167 | int r; | - | ||||||||||||
| 168 | size_t len; | - | ||||||||||||
| 169 | u_char *val; | - | ||||||||||||
| 170 | - | |||||||||||||
| 171 | if ((
| 0 | ||||||||||||
| 172 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 173 | if (length_ptr !=
| 0 | ||||||||||||
| 174 | ((void *)0)
| 0 | ||||||||||||
| 175 | ) | - | ||||||||||||
| 176 | * never executed: length_ptr = (u_int)len;*length_ptr = (u_int)len;never executed: *length_ptr = (u_int)len; | 0 | ||||||||||||
| 177 | return never executed: val;return val;never executed: return val; | 0 | ||||||||||||
| 178 | } | - | ||||||||||||
| 179 | - | |||||||||||||
| 180 | const void * | - | ||||||||||||
| 181 | ssh_packet_get_string_ptr(struct ssh *ssh, u_int *length_ptr) | - | ||||||||||||
| 182 | { | - | ||||||||||||
| 183 | int r; | - | ||||||||||||
| 184 | size_t len; | - | ||||||||||||
| 185 | const u_char *val; | - | ||||||||||||
| 186 | - | |||||||||||||
| 187 | if ((
| 0 | ||||||||||||
| 188 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 189 | if (length_ptr !=
| 0 | ||||||||||||
| 190 | ((void *)0)
| 0 | ||||||||||||
| 191 | ) | - | ||||||||||||
| 192 | * never executed: length_ptr = (u_int)len;*length_ptr = (u_int)len;never executed: *length_ptr = (u_int)len; | 0 | ||||||||||||
| 193 | return never executed: val;return val;never executed: return val; | 0 | ||||||||||||
| 194 | } | - | ||||||||||||
| 195 | - | |||||||||||||
| 196 | char * | - | ||||||||||||
| 197 | ssh_packet_get_cstring(struct ssh *ssh, u_int *length_ptr) | - | ||||||||||||
| 198 | { | - | ||||||||||||
| 199 | int r; | - | ||||||||||||
| 200 | size_t len; | - | ||||||||||||
| 201 | char *val; | - | ||||||||||||
| 202 | - | |||||||||||||
| 203 | if ((
| 0 | ||||||||||||
| 204 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 | ||||||||||||
| 205 | if (length_ptr !=
| 0 | ||||||||||||
| 206 | ((void *)0)
| 0 | ||||||||||||
| 207 | ) | - | ||||||||||||
| 208 | * never executed: length_ptr = (u_int)len;*length_ptr = (u_int)len;never executed: *length_ptr = (u_int)len; | 0 | ||||||||||||
| 209 | return never executed: val;return val;never executed: return val; | 0 | ||||||||||||
| 210 | } | - | ||||||||||||
| 211 | - | |||||||||||||
| 212 | - | |||||||||||||
| 213 | - | |||||||||||||
| 214 | void | - | ||||||||||||
| 215 | packet_set_connection(int fd_in, int fd_out) | - | ||||||||||||
| 216 | { | - | ||||||||||||
| 217 | active_state = ssh_packet_set_connection(active_state, fd_in, fd_out); | - | ||||||||||||
| 218 | if (active_state ==
| 0 | ||||||||||||
| 219 | ((void *)0)
| 0 | ||||||||||||
| 220 | ) | - | ||||||||||||
| 221 | fatal("%s: ssh_packet_set_connection failed", __func__); never executed: fatal("%s: ssh_packet_set_connection failed", __func__); | 0 | ||||||||||||
| 222 | } never executed: end of block | 0 | ||||||||||||
| 223 | - | |||||||||||||
| 224 | u_int | - | ||||||||||||
| 225 | packet_get_char(void) | - | ||||||||||||
| 226 | { | - | ||||||||||||
| 227 | return never executed: (ssh_packet_get_char(active_state));return (ssh_packet_get_char(active_state));never executed: return (ssh_packet_get_char(active_state)); | 0 | ||||||||||||
| 228 | } | - | ||||||||||||
| 229 | - | |||||||||||||
| 230 | u_int | - | ||||||||||||
| 231 | packet_get_int(void) | - | ||||||||||||
| 232 | { | - | ||||||||||||
| 233 | return never executed: (ssh_packet_get_int(active_state));return (ssh_packet_get_int(active_state));never executed: return (ssh_packet_get_int(active_state)); | 0 | ||||||||||||
| 234 | } | - | ||||||||||||
| 235 | - | |||||||||||||
| 236 | int | - | ||||||||||||
| 237 | packet_read_seqnr(u_int32_t *seqnr) | - | ||||||||||||
| 238 | { | - | ||||||||||||
| 239 | u_char type; | - | ||||||||||||
| 240 | int r; | - | ||||||||||||
| 241 | - | |||||||||||||
| 242 | if ((
| 0 | ||||||||||||
| 243 | sshpkt_fatal(active_state, __func__, r); never executed: sshpkt_fatal(active_state, __func__, r); | 0 | ||||||||||||
| 244 | return never executed: type;return type;never executed: return type; | 0 | ||||||||||||
| 245 | } | - | ||||||||||||
| 246 | - | |||||||||||||
| 247 | int | - | ||||||||||||
| 248 | packet_read_poll_seqnr(u_int32_t *seqnr) | - | ||||||||||||
| 249 | { | - | ||||||||||||
| 250 | u_char type; | - | ||||||||||||
| 251 | int r; | - | ||||||||||||
| 252 | - | |||||||||||||
| 253 | if ((
| 0 | ||||||||||||
| 254 | sshpkt_fatal(active_state, __func__, r); never executed: sshpkt_fatal(active_state, __func__, r); | 0 | ||||||||||||
| 255 | return never executed: type;return type;never executed: return type; | 0 | ||||||||||||
| 256 | } | - | ||||||||||||
| 257 | - | |||||||||||||
| 258 | void | - | ||||||||||||
| 259 | packet_close(void) | - | ||||||||||||
| 260 | { | - | ||||||||||||
| 261 | ssh_packet_close(active_state); | - | ||||||||||||
| 262 | active_state = | - | ||||||||||||
| 263 | ((void *)0) | - | ||||||||||||
| 264 | ; | - | ||||||||||||
| 265 | } never executed: end of block | 0 | ||||||||||||
| 266 | - | |||||||||||||
| 267 | void | - | ||||||||||||
| 268 | packet_process_incoming(const char *buf, u_int len) | - | ||||||||||||
| 269 | { | - | ||||||||||||
| 270 | int r; | - | ||||||||||||
| 271 | - | |||||||||||||
| 272 | if ((
| 0 | ||||||||||||
| 273 | sshpkt_fatal(active_state, __func__, r); never executed: sshpkt_fatal(active_state, __func__, r); | 0 | ||||||||||||
| 274 | } never executed: end of block | 0 | ||||||||||||
| 275 | - | |||||||||||||
| 276 | void | - | ||||||||||||
| 277 | packet_write_wait(void) | - | ||||||||||||
| 278 | { | - | ||||||||||||
| 279 | int r; | - | ||||||||||||
| 280 | - | |||||||||||||
| 281 | if ((
| 0 | ||||||||||||
| 282 | sshpkt_fatal(active_state, __func__, r); never executed: sshpkt_fatal(active_state, __func__, r); | 0 | ||||||||||||
| 283 | } never executed: end of block | 0 | ||||||||||||
| 284 | - | |||||||||||||
| 285 | void | - | ||||||||||||
| 286 | packet_write_poll(void) | - | ||||||||||||
| 287 | { | - | ||||||||||||
| 288 | int r; | - | ||||||||||||
| 289 | - | |||||||||||||
| 290 | if ((
| 0 | ||||||||||||
| 291 | sshpkt_fatal(active_state, __func__, r); never executed: sshpkt_fatal(active_state, __func__, r); | 0 | ||||||||||||
| 292 | } never executed: end of block | 0 | ||||||||||||
| 293 | - | |||||||||||||
| 294 | void | - | ||||||||||||
| 295 | packet_read_expect(int expected_type) | - | ||||||||||||
| 296 | { | - | ||||||||||||
| 297 | int r; | - | ||||||||||||
| 298 | - | |||||||||||||
| 299 | if ((
| 0 | ||||||||||||
| 300 | sshpkt_fatal(active_state, __func__, r); never executed: sshpkt_fatal(active_state, __func__, r); | 0 | ||||||||||||
| 301 | } never executed: end of block | 0 | ||||||||||||
| 302 | - | |||||||||||||
| 303 | void | - | ||||||||||||
| 304 | packet_disconnect(const char *fmt, ...) | - | ||||||||||||
| 305 | { | - | ||||||||||||
| 306 | char buf[1024]; | - | ||||||||||||
| 307 | va_list args; | - | ||||||||||||
| 308 | - | |||||||||||||
| 309 | - | |||||||||||||
| 310 | __builtin_va_start( | - | ||||||||||||
| 311 | args | - | ||||||||||||
| 312 | , | - | ||||||||||||
| 313 | fmt | - | ||||||||||||
| 314 | ) | - | ||||||||||||
| 315 | ; | - | ||||||||||||
| 316 | vsnprintf(buf, sizeof(buf), fmt, args); | - | ||||||||||||
| 317 | - | |||||||||||||
| 318 | __builtin_va_end( | - | ||||||||||||
| 319 | args | - | ||||||||||||
| 320 | ) | - | ||||||||||||
| 321 | ; | - | ||||||||||||
| 322 | ssh_packet_disconnect(active_state, "%s", buf); | - | ||||||||||||
| 323 | } never executed: end of block | 0 | ||||||||||||
| 324 | - | |||||||||||||
| 325 | void | - | ||||||||||||
| 326 | packet_send_debug(const char *fmt, ...) | - | ||||||||||||
| 327 | { | - | ||||||||||||
| 328 | char buf[1024]; | - | ||||||||||||
| 329 | va_list args; | - | ||||||||||||
| 330 | - | |||||||||||||
| 331 | - | |||||||||||||
| 332 | __builtin_va_start( | - | ||||||||||||
| 333 | args | - | ||||||||||||
| 334 | , | - | ||||||||||||
| 335 | fmt | - | ||||||||||||
| 336 | ) | - | ||||||||||||
| 337 | ; | - | ||||||||||||
| 338 | vsnprintf(buf, sizeof(buf), fmt, args); | - | ||||||||||||
| 339 | - | |||||||||||||
| 340 | __builtin_va_end( | - | ||||||||||||
| 341 | args | - | ||||||||||||
| 342 | ) | - | ||||||||||||
| 343 | ; | - | ||||||||||||
| 344 | ssh_packet_send_debug(active_state, "%s", buf); | - | ||||||||||||
| 345 | } never executed: end of block | 0 | ||||||||||||
| Switch to Source code | Preprocessed file |