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