| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bio/b_sock.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | int BIO_get_host_ip(const char *str, unsigned char *ip) | - | ||||||||||||
| 2 | { | - | ||||||||||||
| 3 | BIO_ADDRINFO *res = | - | ||||||||||||
| 4 | ((void *)0) | - | ||||||||||||
| 5 | ; | - | ||||||||||||
| 6 | int ret = 0; | - | ||||||||||||
| 7 | - | |||||||||||||
| 8 | if (BIO_sock_init() != 1
| 0 | ||||||||||||
| 9 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 10 | - | |||||||||||||
| 11 | if (BIO_lookup(str,
| 0 | ||||||||||||
| 12 | ((void *)0)
| 0 | ||||||||||||
| 13 | , BIO_LOOKUP_CLIENT,
| 0 | ||||||||||||
| 14 | 2
| 0 | ||||||||||||
| 15 | ,
| 0 | ||||||||||||
| 16 | SOCK_STREAM
| 0 | ||||||||||||
| 17 | , &res)
| 0 | ||||||||||||
| 18 | size_t l; | - | ||||||||||||
| 19 | - | |||||||||||||
| 20 | if (BIO_ADDRINFO_family(res) !=
| 0 | ||||||||||||
| 21 | 2
| 0 | ||||||||||||
| 22 | ) { | - | ||||||||||||
| 23 | ERR_put_error(32,(106),(107),__FILE__,41) | - | ||||||||||||
| 24 | ; | - | ||||||||||||
| 25 | } never executed: else if (BIO_ADDR_rawaddress(BIO_ADDRINFO_address(res), end of block
| 0 | ||||||||||||
| 26 | ((void *)0)
| 0 | ||||||||||||
| 27 | , &l)
| 0 | ||||||||||||
| 28 | - | |||||||||||||
| 29 | - | |||||||||||||
| 30 | - | |||||||||||||
| 31 | - | |||||||||||||
| 32 | if (((
| 0 | ||||||||||||
| 33 | ret = BIO_ADDR_rawaddress(BIO_ADDRINFO_address(res), ip, &l); never executed: ret = BIO_ADDR_rawaddress(BIO_ADDRINFO_address(res), ip, &l); | 0 | ||||||||||||
| 34 | } never executed: end of block | 0 | ||||||||||||
| 35 | BIO_ADDRINFO_free(res); | - | ||||||||||||
| 36 | } never executed: else {end of block | 0 | ||||||||||||
| 37 | ERR_add_error_data(2, "host=", str); | - | ||||||||||||
| 38 | } never executed: end of block | 0 | ||||||||||||
| 39 | - | |||||||||||||
| 40 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||
| 41 | } | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | int BIO_get_port(const char *str, unsigned short *port_ptr) | - | ||||||||||||
| 44 | { | - | ||||||||||||
| 45 | BIO_ADDRINFO *res = | - | ||||||||||||
| 46 | ((void *)0) | - | ||||||||||||
| 47 | ; | - | ||||||||||||
| 48 | int ret = 0; | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | if (str ==
| 0 | ||||||||||||
| 51 | ((void *)0)
| 0 | ||||||||||||
| 52 | ) { | - | ||||||||||||
| 53 | ERR_put_error(32,(107),(113),__FILE__,64); | - | ||||||||||||
| 54 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 55 | } | - | ||||||||||||
| 56 | - | |||||||||||||
| 57 | if (BIO_sock_init() != 1
| 0 | ||||||||||||
| 58 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 59 | - | |||||||||||||
| 60 | if (BIO_lookup(
| 0 | ||||||||||||
| 61 | ((void *)0)
| 0 | ||||||||||||
| 62 | , str, BIO_LOOKUP_CLIENT,
| 0 | ||||||||||||
| 63 | 2
| 0 | ||||||||||||
| 64 | ,
| 0 | ||||||||||||
| 65 | SOCK_STREAM
| 0 | ||||||||||||
| 66 | , &res)
| 0 | ||||||||||||
| 67 | if (BIO_ADDRINFO_family(res) !=
| 0 | ||||||||||||
| 68 | 2
| 0 | ||||||||||||
| 69 | ) { | - | ||||||||||||
| 70 | ERR_put_error(32,(107),(141),__FILE__,74) | - | ||||||||||||
| 71 | ; | - | ||||||||||||
| 72 | } never executed: else {end of block | 0 | ||||||||||||
| 73 | *port_ptr = | - | ||||||||||||
| 74 | (__extension__ ({ unsigned short int __v, __x = (unsigned short int) ( | - | ||||||||||||
| 75 | BIO_ADDR_rawport(BIO_ADDRINFO_address(res)) | - | ||||||||||||
| 76 | ); if (__builtin_constant_p (__x)
never executed: else __asm____v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));never executed: ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");__asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");never executed: __v; }))__asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc"); | 0 | ||||||||||||
| 77 | ; | - | ||||||||||||
| 78 | ret = 1; | - | ||||||||||||
| 79 | } never executed: end of block | 0 | ||||||||||||
| 80 | BIO_ADDRINFO_free(res); | - | ||||||||||||
| 81 | } never executed: else {end of block | 0 | ||||||||||||
| 82 | ERR_add_error_data(2, "host=", str); | - | ||||||||||||
| 83 | } never executed: end of block | 0 | ||||||||||||
| 84 | - | |||||||||||||
| 85 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||
| 86 | } | - | ||||||||||||
| 87 | - | |||||||||||||
| 88 | - | |||||||||||||
| 89 | int BIO_sock_error(int sock) | - | ||||||||||||
| 90 | { | - | ||||||||||||
| 91 | int j = 0, i; | - | ||||||||||||
| 92 | socklen_t size = sizeof(j); | - | ||||||||||||
| 93 | - | |||||||||||||
| 94 | - | |||||||||||||
| 95 | - | |||||||||||||
| 96 | - | |||||||||||||
| 97 | - | |||||||||||||
| 98 | - | |||||||||||||
| 99 | - | |||||||||||||
| 100 | i = getsockopt(sock, | - | ||||||||||||
| 101 | 1 | - | ||||||||||||
| 102 | , | - | ||||||||||||
| 103 | 4 | - | ||||||||||||
| 104 | , (void *)&j, &size); | - | ||||||||||||
| 105 | if (i < 0
| 0-2 | ||||||||||||
| 106 | return never executed: return (*__errno_location ()) ;never executed: return (*__errno_location ()) ; | 0 | ||||||||||||
| 107 | (*__errno_location ()) never executed: return (*__errno_location ()) ; | 0 | ||||||||||||
| 108 | ; never executed: return (*__errno_location ()) ; | 0 | ||||||||||||
| 109 | else | - | ||||||||||||
| 110 | return executed 2 times by 1 test: j;return j;Executed by:
executed 2 times by 1 test: return j;Executed by:
| 2 | ||||||||||||
| 111 | } | - | ||||||||||||
| 112 | - | |||||||||||||
| 113 | - | |||||||||||||
| 114 | struct hostent *BIO_gethostbyname(const char *name) | - | ||||||||||||
| 115 | { | - | ||||||||||||
| 116 | - | |||||||||||||
| 117 | - | |||||||||||||
| 118 | - | |||||||||||||
| 119 | - | |||||||||||||
| 120 | return never executed: gethostbyname(name);return gethostbyname(name);never executed: return gethostbyname(name); | 0 | ||||||||||||
| 121 | } | - | ||||||||||||
| 122 | - | |||||||||||||
| 123 | - | |||||||||||||
| 124 | int BIO_sock_init(void) | - | ||||||||||||
| 125 | { | - | ||||||||||||
| 126 | return executed 1469 times by 1 test: 1;return 1;Executed by:
executed 1469 times by 1 test: return 1;Executed by:
| 1469 | ||||||||||||
| 127 | } | - | ||||||||||||
| 128 | - | |||||||||||||
| 129 | void bio_sock_cleanup_int(void) | - | ||||||||||||
| 130 | { | - | ||||||||||||
| 131 | - | |||||||||||||
| 132 | - | |||||||||||||
| 133 | - | |||||||||||||
| 134 | - | |||||||||||||
| 135 | - | |||||||||||||
| 136 | - | |||||||||||||
| 137 | } | - | ||||||||||||
| 138 | - | |||||||||||||
| 139 | int BIO_socket_ioctl(int fd, long type, void *arg) | - | ||||||||||||
| 140 | { | - | ||||||||||||
| 141 | int i; | - | ||||||||||||
| 142 | i = ioctl(fd,type,arg); | - | ||||||||||||
| 143 | - | |||||||||||||
| 144 | if (i < 0
| 0-564 | ||||||||||||
| 145 | ERR_put_error(2,(5),( never executed: ERR_put_error(2,(5),( (*__errno_location ()) ),__FILE__,195); | 0 | ||||||||||||
| 146 | (*__errno_location ()) never executed: ERR_put_error(2,(5),( (*__errno_location ()) ),__FILE__,195); | 0 | ||||||||||||
| 147 | ),__FILE__,195); never executed: ERR_put_error(2,(5),( (*__errno_location ()) ),__FILE__,195); | 0 | ||||||||||||
| 148 | return executed 564 times by 1 test: i;return i;Executed by:
executed 564 times by 1 test: return i;Executed by:
| 564 | ||||||||||||
| 149 | } | - | ||||||||||||
| 150 | - | |||||||||||||
| 151 | - | |||||||||||||
| 152 | int BIO_get_accept_socket(char *host, int bind_mode) | - | ||||||||||||
| 153 | { | - | ||||||||||||
| 154 | int s = (-1); | - | ||||||||||||
| 155 | char *h = | - | ||||||||||||
| 156 | ((void *)0) | - | ||||||||||||
| 157 | , *p = | - | ||||||||||||
| 158 | ((void *)0) | - | ||||||||||||
| 159 | ; | - | ||||||||||||
| 160 | BIO_ADDRINFO *res = | - | ||||||||||||
| 161 | ((void *)0) | - | ||||||||||||
| 162 | ; | - | ||||||||||||
| 163 | - | |||||||||||||
| 164 | if (!BIO_parse_hostserv(host, &h, &p, BIO_PARSE_PRIO_SERV)
| 0 | ||||||||||||
| 165 | return never executed: (-1);return (-1);never executed: return (-1); | 0 | ||||||||||||
| 166 | - | |||||||||||||
| 167 | if (BIO_sock_init() != 1
| 0 | ||||||||||||
| 168 | return never executed: (-1);return (-1);never executed: return (-1); | 0 | ||||||||||||
| 169 | - | |||||||||||||
| 170 | if (BIO_lookup(h, p, BIO_LOOKUP_SERVER,
| 0 | ||||||||||||
| 171 | 0
| 0 | ||||||||||||
| 172 | ,
| 0 | ||||||||||||
| 173 | SOCK_STREAM
| 0 | ||||||||||||
| 174 | , &res) != 0
| 0 | ||||||||||||
| 175 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 176 | - | |||||||||||||
| 177 | if ((
| 0 | ||||||||||||
| 178 | BIO_ADDRINFO_protocol(res), 0)) == (-1)
| 0 | ||||||||||||
| 179 | s = (-1); | - | ||||||||||||
| 180 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 181 | } | - | ||||||||||||
| 182 | - | |||||||||||||
| 183 | if (!BIO_listen(s, BIO_ADDRINFO_address(res),
| 0 | ||||||||||||
| 184 | bind_mode ? 0x01 : 0)
| 0 | ||||||||||||
| 185 | BIO_closesocket(s); | - | ||||||||||||
| 186 | s = (-1); | - | ||||||||||||
| 187 | } never executed: end of block | 0 | ||||||||||||
| 188 | - | |||||||||||||
| 189 | err: code before this statement never executed: err: | 0 | ||||||||||||
| 190 | BIO_ADDRINFO_free(res); | - | ||||||||||||
| 191 | CRYPTO_free(h, __FILE__, 229); | - | ||||||||||||
| 192 | CRYPTO_free(p, __FILE__, 230); | - | ||||||||||||
| 193 | - | |||||||||||||
| 194 | return never executed: s;return s;never executed: return s; | 0 | ||||||||||||
| 195 | } | - | ||||||||||||
| 196 | - | |||||||||||||
| 197 | int BIO_accept(int sock, char **ip_port) | - | ||||||||||||
| 198 | { | - | ||||||||||||
| 199 | BIO_ADDR res; | - | ||||||||||||
| 200 | int ret = -1; | - | ||||||||||||
| 201 | - | |||||||||||||
| 202 | ret = BIO_accept_ex(sock, &res, 0); | - | ||||||||||||
| 203 | if (ret == (int)(-1)
| 0 | ||||||||||||
| 204 | if (BIO_sock_should_retry(ret)
| 0 | ||||||||||||
| 205 | ret = -2; | - | ||||||||||||
| 206 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||
| 207 | } | - | ||||||||||||
| 208 | ERR_put_error(2,(8),( | - | ||||||||||||
| 209 | (*__errno_location ()) | - | ||||||||||||
| 210 | ),__FILE__,246); | - | ||||||||||||
| 211 | ERR_put_error(32,(101),(100),__FILE__,247); | - | ||||||||||||
| 212 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||
| 213 | } | - | ||||||||||||
| 214 | - | |||||||||||||
| 215 | if (ip_port !=
| 0 | ||||||||||||
| 216 | ((void *)0)
| 0 | ||||||||||||
| 217 | ) { | - | ||||||||||||
| 218 | char *host = BIO_ADDR_hostname_string(&res, 1); | - | ||||||||||||
| 219 | char *port = BIO_ADDR_service_string(&res, 1); | - | ||||||||||||
| 220 | if (host !=
| 0 | ||||||||||||
| 221 | ((void *)0)
| 0 | ||||||||||||
| 222 | && port !=
| 0 | ||||||||||||
| 223 | ((void *)0)
| 0 | ||||||||||||
| 224 | ) | - | ||||||||||||
| 225 | * never executed: ip_port = CRYPTO_zalloc(strlen(host) + strlen(port) + 2, __FILE__, 255);*ip_port = CRYPTO_zalloc(strlen(host) + strlen(port) + 2, __FILE__, 255);never executed: *ip_port = CRYPTO_zalloc(strlen(host) + strlen(port) + 2, __FILE__, 255); | 0 | ||||||||||||
| 226 | else | - | ||||||||||||
| 227 | * never executed: ip_port = *ip_port = ((void *)0) ;never executed: *ip_port = ((void *)0) ; | 0 | ||||||||||||
| 228 | ((void *)0) never executed: *ip_port = ((void *)0) ; | 0 | ||||||||||||
| 229 | ; never executed: *ip_port = ((void *)0) ; | 0 | ||||||||||||
| 230 | - | |||||||||||||
| 231 | if (*
| 0 | ||||||||||||
| 232 | ((void *)0)
| 0 | ||||||||||||
| 233 | ) { | - | ||||||||||||
| 234 | ERR_put_error(32,(101),((1|64)),__FILE__,260); | - | ||||||||||||
| 235 | BIO_closesocket(ret); | - | ||||||||||||
| 236 | ret = (int)(-1); | - | ||||||||||||
| 237 | } never executed: else {end of block | 0 | ||||||||||||
| 238 | strcpy(*ip_port, host); | - | ||||||||||||
| 239 | strcat(*ip_port, ":"); | - | ||||||||||||
| 240 | strcat(*ip_port, port); | - | ||||||||||||
| 241 | } never executed: end of block | 0 | ||||||||||||
| 242 | CRYPTO_free(host, __FILE__, 268); | - | ||||||||||||
| 243 | CRYPTO_free(port, __FILE__, 269); | - | ||||||||||||
| 244 | } never executed: end of block | 0 | ||||||||||||
| 245 | - | |||||||||||||
| 246 | end: code before this statement never executed: end: | 0 | ||||||||||||
| 247 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||
| 248 | } | - | ||||||||||||
| 249 | - | |||||||||||||
| 250 | - | |||||||||||||
| 251 | int BIO_set_tcp_ndelay(int s, int on) | - | ||||||||||||
| 252 | { | - | ||||||||||||
| 253 | int ret = 0; | - | ||||||||||||
| 254 | - | |||||||||||||
| 255 | int opt; | - | ||||||||||||
| 256 | - | |||||||||||||
| 257 | - | |||||||||||||
| 258 | opt = | - | ||||||||||||
| 259 | 6 | - | ||||||||||||
| 260 | ; | - | ||||||||||||
| 261 | - | |||||||||||||
| 262 | - | |||||||||||||
| 263 | - | |||||||||||||
| 264 | - | |||||||||||||
| 265 | - | |||||||||||||
| 266 | - | |||||||||||||
| 267 | ret = setsockopt(s, opt, | - | ||||||||||||
| 268 | 1 | - | ||||||||||||
| 269 | , (char *)&on, sizeof(on)); | - | ||||||||||||
| 270 | - | |||||||||||||
| 271 | return executed 191 times by 1 test: (ret == 0);return (ret == 0);Executed by:
executed 191 times by 1 test: return (ret == 0);Executed by:
| 191 | ||||||||||||
| 272 | } | - | ||||||||||||
| 273 | - | |||||||||||||
| 274 | int BIO_socket_nbio(int s, int mode) | - | ||||||||||||
| 275 | { | - | ||||||||||||
| 276 | int ret = -1; | - | ||||||||||||
| 277 | int l; | - | ||||||||||||
| 278 | - | |||||||||||||
| 279 | l = mode; | - | ||||||||||||
| 280 | - | |||||||||||||
| 281 | l = mode; | - | ||||||||||||
| 282 | - | |||||||||||||
| 283 | ret = BIO_socket_ioctl(s, | - | ||||||||||||
| 284 | 0x5421 | - | ||||||||||||
| 285 | , &l); | - | ||||||||||||
| 286 | return executed 564 times by 1 test: (ret == 0);return (ret == 0);Executed by:
executed 564 times by 1 test: return (ret == 0);Executed by:
| 564 | ||||||||||||
| 287 | } | - | ||||||||||||
| 288 | - | |||||||||||||
| 289 | int BIO_sock_info(int sock, | - | ||||||||||||
| 290 | enum BIO_sock_info_type type, union BIO_sock_info_u *info) | - | ||||||||||||
| 291 | { | - | ||||||||||||
| 292 | switch (type) { | - | ||||||||||||
| 293 | case executed 178 times by 1 test: BIO_SOCK_INFO_ADDRESS:case BIO_SOCK_INFO_ADDRESS:Executed by:
executed 178 times by 1 test: case BIO_SOCK_INFO_ADDRESS:Executed by:
| 178 | ||||||||||||
| 294 | { | - | ||||||||||||
| 295 | socklen_t addr_len; | - | ||||||||||||
| 296 | int ret = 0; | - | ||||||||||||
| 297 | addr_len = sizeof(*info->addr); | - | ||||||||||||
| 298 | ret = getsockname(sock, BIO_ADDR_sockaddr_noconst(info->addr), | - | ||||||||||||
| 299 | &addr_len); | - | ||||||||||||
| 300 | if (ret == -1
| 0-178 | ||||||||||||
| 301 | ERR_put_error(2,(16),( | - | ||||||||||||
| 302 | (*__errno_location ()) | - | ||||||||||||
| 303 | ),__FILE__,352); | - | ||||||||||||
| 304 | ERR_put_error(32,(141),(132),__FILE__,353); | - | ||||||||||||
| 305 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 306 | } | - | ||||||||||||
| 307 | if ((
| 0-178 | ||||||||||||
| 308 | ERR_put_error(32,(141),(133),__FILE__,357); | - | ||||||||||||
| 309 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 310 | } | - | ||||||||||||
| 311 | } | - | ||||||||||||
| 312 | break; executed 178 times by 1 test: break;Executed by:
| 178 | ||||||||||||
| 313 | default never executed: :default:never executed: default: | 0 | ||||||||||||
| 314 | ERR_put_error(32,(141),(140),__FILE__,363); | - | ||||||||||||
| 315 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 316 | } | - | ||||||||||||
| 317 | return executed 178 times by 1 test: 1;return 1;Executed by:
executed 178 times by 1 test: return 1;Executed by:
| 178 | ||||||||||||
| 318 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |