| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/bio/bss_sock.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | static int sock_write(BIO *h, const char *buf, int num); | - | ||||||||||||||||||||||||
| 5 | static int sock_read(BIO *h, char *buf, int size); | - | ||||||||||||||||||||||||
| 6 | static int sock_puts(BIO *h, const char *str); | - | ||||||||||||||||||||||||
| 7 | static long sock_ctrl(BIO *h, int cmd, long arg1, void *arg2); | - | ||||||||||||||||||||||||
| 8 | static int sock_new(BIO *h); | - | ||||||||||||||||||||||||
| 9 | static int sock_free(BIO *data); | - | ||||||||||||||||||||||||
| 10 | int BIO_sock_should_retry(int s); | - | ||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | static const BIO_METHOD methods_sockp = { | - | ||||||||||||||||||||||||
| 13 | .type = (5|0x0400|0x0100), | - | ||||||||||||||||||||||||
| 14 | .name = "socket", | - | ||||||||||||||||||||||||
| 15 | .bwrite = sock_write, | - | ||||||||||||||||||||||||
| 16 | .bread = sock_read, | - | ||||||||||||||||||||||||
| 17 | .bputs = sock_puts, | - | ||||||||||||||||||||||||
| 18 | .ctrl = sock_ctrl, | - | ||||||||||||||||||||||||
| 19 | .create = sock_new, | - | ||||||||||||||||||||||||
| 20 | .destroy = sock_free | - | ||||||||||||||||||||||||
| 21 | }; | - | ||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||
| 23 | const BIO_METHOD * | - | ||||||||||||||||||||||||
| 24 | BIO_s_socket(void) | - | ||||||||||||||||||||||||
| 25 | { | - | ||||||||||||||||||||||||
| 26 | return executed 6 times by 1 test: (&methods_sockp);return (&methods_sockp);Executed by:
executed 6 times by 1 test: return (&methods_sockp);Executed by:
| 6 | ||||||||||||||||||||||||
| 27 | } | - | ||||||||||||||||||||||||
| 28 | - | |||||||||||||||||||||||||
| 29 | BIO * | - | ||||||||||||||||||||||||
| 30 | BIO_new_socket(int fd, int close_flag) | - | ||||||||||||||||||||||||
| 31 | { | - | ||||||||||||||||||||||||
| 32 | BIO *ret; | - | ||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||
| 34 | ret = BIO_new(BIO_s_socket()); | - | ||||||||||||||||||||||||
| 35 | if (ret ==
| 0 | ||||||||||||||||||||||||
| 36 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 37 | ) | - | ||||||||||||||||||||||||
| 38 | return never executed: (return ( ((void *)0) );never executed: return ( ((void *)0) ); | 0 | ||||||||||||||||||||||||
| 39 | ((void *)0) never executed: return ( ((void *)0) ); | 0 | ||||||||||||||||||||||||
| 40 | ); never executed: return ( ((void *)0) ); | 0 | ||||||||||||||||||||||||
| 41 | BIO_int_ctrl(ret,104,close_flag,fd); | - | ||||||||||||||||||||||||
| 42 | return never executed: (ret);return (ret);never executed: return (ret); | 0 | ||||||||||||||||||||||||
| 43 | } | - | ||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | static int | - | ||||||||||||||||||||||||
| 46 | sock_new(BIO *bi) | - | ||||||||||||||||||||||||
| 47 | { | - | ||||||||||||||||||||||||
| 48 | bi->init = 0; | - | ||||||||||||||||||||||||
| 49 | bi->num = 0; | - | ||||||||||||||||||||||||
| 50 | bi->ptr = | - | ||||||||||||||||||||||||
| 51 | ((void *)0) | - | ||||||||||||||||||||||||
| 52 | ; | - | ||||||||||||||||||||||||
| 53 | bi->flags = 0; | - | ||||||||||||||||||||||||
| 54 | return executed 6 times by 1 test: (1);return (1);Executed by:
executed 6 times by 1 test: return (1);Executed by:
| 6 | ||||||||||||||||||||||||
| 55 | } | - | ||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||
| 57 | static int | - | ||||||||||||||||||||||||
| 58 | sock_free(BIO *a) | - | ||||||||||||||||||||||||
| 59 | { | - | ||||||||||||||||||||||||
| 60 | if (a ==
| 0-12 | ||||||||||||||||||||||||
| 61 | ((void *)0)
| 0-12 | ||||||||||||||||||||||||
| 62 | ) | - | ||||||||||||||||||||||||
| 63 | return never executed: (0);return (0);never executed: return (0); | 0 | ||||||||||||||||||||||||
| 64 | if (a->shutdown
| 6 | ||||||||||||||||||||||||
| 65 | if (a->init
| 0-6 | ||||||||||||||||||||||||
| 66 | shutdown(a->num, | - | ||||||||||||||||||||||||
| 67 | SHUT_RDWR | - | ||||||||||||||||||||||||
| 68 | ); | - | ||||||||||||||||||||||||
| 69 | close(a->num); | - | ||||||||||||||||||||||||
| 70 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 71 | a->init = 0; | - | ||||||||||||||||||||||||
| 72 | a->flags = 0; | - | ||||||||||||||||||||||||
| 73 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 74 | return executed 12 times by 1 test: (1);return (1);Executed by:
executed 12 times by 1 test: return (1);Executed by:
| 12 | ||||||||||||||||||||||||
| 75 | } | - | ||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 | static int | - | ||||||||||||||||||||||||
| 78 | sock_read(BIO *b, char *out, int outl) | - | ||||||||||||||||||||||||
| 79 | { | - | ||||||||||||||||||||||||
| 80 | int ret = 0; | - | ||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | if (out !=
| 0-46 | ||||||||||||||||||||||||
| 83 | ((void *)0)
| 0-46 | ||||||||||||||||||||||||
| 84 | ) { | - | ||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||
| 86 | (*__errno_location ()) | - | ||||||||||||||||||||||||
| 87 | = 0; | - | ||||||||||||||||||||||||
| 88 | ret = read(b->num, out, outl); | - | ||||||||||||||||||||||||
| 89 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||||||||
| 90 | if (ret <= 0
| 6-40 | ||||||||||||||||||||||||
| 91 | if (BIO_sock_should_retry(ret)
| 0-6 | ||||||||||||||||||||||||
| 92 | BIO_set_flags(b, (0x01|0x08)); executed 6 times by 1 test: BIO_set_flags(b, (0x01|0x08));Executed by:
| 6 | ||||||||||||||||||||||||
| 93 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 94 | } executed 46 times by 1 test: end of blockExecuted by:
| 46 | ||||||||||||||||||||||||
| 95 | return executed 46 times by 1 test: (ret);return (ret);Executed by:
executed 46 times by 1 test: return (ret);Executed by:
| 46 | ||||||||||||||||||||||||
| 96 | } | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | static int | - | ||||||||||||||||||||||||
| 99 | sock_write(BIO *b, const char *in, int inl) | - | ||||||||||||||||||||||||
| 100 | { | - | ||||||||||||||||||||||||
| 101 | int ret; | - | ||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||
| 104 | (*__errno_location ()) | - | ||||||||||||||||||||||||
| 105 | = 0; | - | ||||||||||||||||||||||||
| 106 | ret = write(b->num, in, inl); | - | ||||||||||||||||||||||||
| 107 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||||||||
| 108 | if (ret <= 0
| 0-12 | ||||||||||||||||||||||||
| 109 | if (BIO_sock_should_retry(ret)
| 0 | ||||||||||||||||||||||||
| 110 | BIO_set_flags(b, (0x02|0x08)); never executed: BIO_set_flags(b, (0x02|0x08)); | 0 | ||||||||||||||||||||||||
| 111 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 112 | return executed 12 times by 1 test: (ret);return (ret);Executed by:
executed 12 times by 1 test: return (ret);Executed by:
| 12 | ||||||||||||||||||||||||
| 113 | } | - | ||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||
| 115 | static long | - | ||||||||||||||||||||||||
| 116 | sock_ctrl(BIO *b, int cmd, long num, void *ptr) | - | ||||||||||||||||||||||||
| 117 | { | - | ||||||||||||||||||||||||
| 118 | long ret = 1; | - | ||||||||||||||||||||||||
| 119 | int *ip; | - | ||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||
| 121 | switch (cmd) { | - | ||||||||||||||||||||||||
| 122 | case executed 6 times by 1 test: 104:case 104:Executed by:
executed 6 times by 1 test: case 104:Executed by:
| 6 | ||||||||||||||||||||||||
| 123 | sock_free(b); | - | ||||||||||||||||||||||||
| 124 | b->num= *((int *)ptr); | - | ||||||||||||||||||||||||
| 125 | b->shutdown = (int)num; | - | ||||||||||||||||||||||||
| 126 | b->init = 1; | - | ||||||||||||||||||||||||
| 127 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||||||||||||||||||||
| 128 | case executed 4 times by 1 test: 105:case 105:Executed by:
executed 4 times by 1 test: case 105:Executed by:
| 4 | ||||||||||||||||||||||||
| 129 | if (b->init
| 0-4 | ||||||||||||||||||||||||
| 130 | ip = (int *)ptr; | - | ||||||||||||||||||||||||
| 131 | if (ip !=
| 0-4 | ||||||||||||||||||||||||
| 132 | ((void *)0)
| 0-4 | ||||||||||||||||||||||||
| 133 | ) | - | ||||||||||||||||||||||||
| 134 | * never executed: ip = b->num;*ip = b->num;never executed: *ip = b->num; | 0 | ||||||||||||||||||||||||
| 135 | ret = b->num; | - | ||||||||||||||||||||||||
| 136 | } executed 4 times by 1 test: elseend of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 137 | ret = -1; never executed: ret = -1; | 0 | ||||||||||||||||||||||||
| 138 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 139 | case never executed: 8:case 8:never executed: case 8: | 0 | ||||||||||||||||||||||||
| 140 | ret = b->shutdown; | - | ||||||||||||||||||||||||
| 141 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 142 | case never executed: 9:case 9:never executed: case 9: | 0 | ||||||||||||||||||||||||
| 143 | b->shutdown = (int)num; | - | ||||||||||||||||||||||||
| 144 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 145 | case never executed: 12:case 12:never executed: case 12: | 0 | ||||||||||||||||||||||||
| 146 | case executed 6 times by 1 test: 11:case 11:Executed by:
executed 6 times by 1 test: case 11:Executed by:
| 6 | ||||||||||||||||||||||||
| 147 | ret = 1; | - | ||||||||||||||||||||||||
| 148 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||||||||||||||||||||
| 149 | default executed 8 times by 1 test: :default:Executed by:
executed 8 times by 1 test: default:Executed by:
| 8 | ||||||||||||||||||||||||
| 150 | ret = 0; | - | ||||||||||||||||||||||||
| 151 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||||||||||||||||||||
| 152 | } | - | ||||||||||||||||||||||||
| 153 | return executed 24 times by 1 test: (ret);return (ret);Executed by:
executed 24 times by 1 test: return (ret);Executed by:
| 24 | ||||||||||||||||||||||||
| 154 | } | - | ||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||
| 156 | static int | - | ||||||||||||||||||||||||
| 157 | sock_puts(BIO *bp, const char *str) | - | ||||||||||||||||||||||||
| 158 | { | - | ||||||||||||||||||||||||
| 159 | int n, ret; | - | ||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | n = strlen(str); | - | ||||||||||||||||||||||||
| 162 | ret = sock_write(bp, str, n); | - | ||||||||||||||||||||||||
| 163 | return never executed: (ret);return (ret);never executed: return (ret); | 0 | ||||||||||||||||||||||||
| 164 | } | - | ||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | int | - | ||||||||||||||||||||||||
| 167 | BIO_sock_should_retry(int i) | - | ||||||||||||||||||||||||
| 168 | { | - | ||||||||||||||||||||||||
| 169 | int err; | - | ||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | if ((
| 0-6 | ||||||||||||||||||||||||
| 172 | err = | - | ||||||||||||||||||||||||
| 173 | (*__errno_location ()) | - | ||||||||||||||||||||||||
| 174 | ; | - | ||||||||||||||||||||||||
| 175 | return executed 6 times by 1 test: (BIO_sock_non_fatal_error(err));return (BIO_sock_non_fatal_error(err));Executed by:
executed 6 times by 1 test: return (BIO_sock_non_fatal_error(err));Executed by:
| 6 | ||||||||||||||||||||||||
| 176 | } | - | ||||||||||||||||||||||||
| 177 | return never executed: (0);return (0);never executed: return (0); | 0 | ||||||||||||||||||||||||
| 178 | } | - | ||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | int | - | ||||||||||||||||||||||||
| 181 | BIO_sock_non_fatal_error(int err) | - | ||||||||||||||||||||||||
| 182 | { | - | ||||||||||||||||||||||||
| 183 | switch (err) { | - | ||||||||||||||||||||||||
| 184 | case never executed: case 107 :never executed: case 107 : | 0 | ||||||||||||||||||||||||
| 185 | 107 never executed: case 107 : | 0 | ||||||||||||||||||||||||
| 186 | : never executed: case 107 : | 0 | ||||||||||||||||||||||||
| 187 | case never executed: case 4 :never executed: case 4 : | 0 | ||||||||||||||||||||||||
| 188 | 4 never executed: case 4 : | 0 | ||||||||||||||||||||||||
| 189 | : never executed: case 4 : | 0 | ||||||||||||||||||||||||
| 190 | case executed 6 times by 1 test: case 11 :Executed by:
executed 6 times by 1 test: case 11 :Executed by:
| 6 | ||||||||||||||||||||||||
| 191 | 11 executed 6 times by 1 test: case 11 :Executed by:
| 6 | ||||||||||||||||||||||||
| 192 | : executed 6 times by 1 test: case 11 :Executed by:
| 6 | ||||||||||||||||||||||||
| 193 | case never executed: case 115 :never executed: case 115 : | 0 | ||||||||||||||||||||||||
| 194 | 115 never executed: case 115 : | 0 | ||||||||||||||||||||||||
| 195 | : never executed: case 115 : | 0 | ||||||||||||||||||||||||
| 196 | case never executed: case 114 :never executed: case 114 : | 0 | ||||||||||||||||||||||||
| 197 | 114 never executed: case 114 : | 0 | ||||||||||||||||||||||||
| 198 | : never executed: case 114 : | 0 | ||||||||||||||||||||||||
| 199 | return executed 6 times by 1 test: (1);return (1);Executed by:
executed 6 times by 1 test: return (1);Executed by:
| 6 | ||||||||||||||||||||||||
| 200 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 201 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 202 | } | - | ||||||||||||||||||||||||
| 203 | return never executed: (0);return (0);never executed: return (0); | 0 | ||||||||||||||||||||||||
| 204 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |