Bug Summary

File:out/../deps/openssl/openssl/crypto/bio/bss_acpt.c
Warning:line 273, column 13
Value stored to 's' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name bss_acpt.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/home/maurizio/node-v18.6.0/out -resource-dir /usr/local/lib/clang/16.0.0 -D V8_DEPRECATION_WARNINGS -D V8_IMMINENT_DEPRECATION_WARNINGS -D _GLIBCXX_USE_CXX11_ABI=1 -D NODE_OPENSSL_CONF_NAME=nodejs_conf -D NODE_OPENSSL_HAS_QUIC -D __STDC_FORMAT_MACROS -D OPENSSL_NO_PINSHARED -D OPENSSL_THREADS -D OPENSSL_NO_HW -D OPENSSL_API_COMPAT=0x10100001L -D STATIC_LEGACY -D NDEBUG -D OPENSSL_USE_NODELETE -D L_ENDIAN -D OPENSSL_BUILDING_OPENSSL -D AES_ASM -D BSAES_ASM -D CMLL_ASM -D ECP_NISTZ256_ASM -D GHASH_ASM -D KECCAK1600_ASM -D MD5_ASM -D OPENSSL_BN_ASM_GF2m -D OPENSSL_BN_ASM_MONT -D OPENSSL_BN_ASM_MONT5 -D OPENSSL_CPUID_OBJ -D OPENSSL_IA32_SSE2 -D PADLOCK_ASM -D POLY1305_ASM -D SHA1_ASM -D SHA256_ASM -D SHA512_ASM -D VPAES_ASM -D WHIRLPOOL_ASM -D X25519_ASM -D OPENSSL_PIC -D MODULESDIR="/home/maurizio/node-v18.6.0/out/Release/obj.target/deps/openssl/lib/openssl-modules" -D OPENSSLDIR="/home/maurizio/node-v18.6.0/out/Release/obj.target/deps/openssl" -D OPENSSLDIR="/etc/ssl" -D ENGINESDIR="/dev/null" -D TERMIOS -I ../deps/openssl/openssl -I ../deps/openssl/openssl/include -I ../deps/openssl/openssl/crypto -I ../deps/openssl/openssl/crypto/include -I ../deps/openssl/openssl/crypto/modes -I ../deps/openssl/openssl/crypto/ec/curve448 -I ../deps/openssl/openssl/crypto/ec/curve448/arch_32 -I ../deps/openssl/openssl/providers/common/include -I ../deps/openssl/openssl/providers/implementations/include -I ../deps/openssl/config -I ../deps/openssl/config/archs/linux-x86_64/asm -I ../deps/openssl/config/archs/linux-x86_64/asm/include -I ../deps/openssl/config/archs/linux-x86_64/asm/crypto -I ../deps/openssl/config/archs/linux-x86_64/asm/crypto/include/internal -I ../deps/openssl/config/archs/linux-x86_64/asm/providers/common/include -internal-isystem /usr/local/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-unused-parameter -Wno-missing-field-initializers -Wno-old-style-declaration -fdebug-compilation-dir=/home/maurizio/node-v18.6.0/out -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2022-08-22-142216-507842-1 -x c ../deps/openssl/openssl/crypto/bio/bss_acpt.c
1/*
2 * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#define OPENSSL_SUPPRESS_DEPRECATED
11
12#include <stdio.h>
13#include <errno(*__errno_location ()).h>
14#include "bio_local.h"
15
16#ifndef OPENSSL_NO_SOCK
17
18typedef struct bio_accept_st {
19 int state;
20 int accept_family;
21 int bind_mode; /* Socket mode for BIO_listen */
22 int accepted_mode; /* Socket mode for BIO_accept (set on accepted sock) */
23 char *param_addr;
24 char *param_serv;
25
26 int accept_sock;
27
28 BIO_ADDRINFO *addr_first;
29 const BIO_ADDRINFO *addr_iter;
30 BIO_ADDR cache_accepting_addr; /* Useful if we asked for port 0 */
31 char *cache_accepting_name, *cache_accepting_serv;
32 BIO_ADDR cache_peer_addr;
33 char *cache_peer_name, *cache_peer_serv;
34
35 BIO *bio_chain;
36} BIO_ACCEPT;
37
38static int acpt_write(BIO *h, const char *buf, int num);
39static int acpt_read(BIO *h, char *buf, int size);
40static int acpt_puts(BIO *h, const char *str);
41static long acpt_ctrl(BIO *h, int cmd, long arg1, void *arg2);
42static int acpt_new(BIO *h);
43static int acpt_free(BIO *data);
44static int acpt_state(BIO *b, BIO_ACCEPT *c);
45static void acpt_close_socket(BIO *data);
46static BIO_ACCEPT *BIO_ACCEPT_new(void);
47static void BIO_ACCEPT_free(BIO_ACCEPT *a);
48
49# define ACPT_S_BEFORE1 1
50# define ACPT_S_GET_ADDR2 2
51# define ACPT_S_CREATE_SOCKET3 3
52# define ACPT_S_LISTEN4 4
53# define ACPT_S_ACCEPT5 5
54# define ACPT_S_OK6 6
55
56static const BIO_METHOD methods_acceptp = {
57 BIO_TYPE_ACCEPT(13|0x0400|0x0100),
58 "socket accept",
59 bwrite_conv,
60 acpt_write,
61 bread_conv,
62 acpt_read,
63 acpt_puts,
64 NULL((void*)0), /* connect_gets, */
65 acpt_ctrl,
66 acpt_new,
67 acpt_free,
68 NULL((void*)0), /* connect_callback_ctrl */
69};
70
71const BIO_METHOD *BIO_s_accept(void)
72{
73 return &methods_acceptp;
74}
75
76static int acpt_new(BIO *bi)
77{
78 BIO_ACCEPT *ba;
79
80 bi->init = 0;
81 bi->num = (int)INVALID_SOCKET(-1);
82 bi->flags = 0;
83 if ((ba = BIO_ACCEPT_new()) == NULL((void*)0))
84 return 0;
85 bi->ptr = (char *)ba;
86 ba->state = ACPT_S_BEFORE1;
87 bi->shutdown = 1;
88 return 1;
89}
90
91static BIO_ACCEPT *BIO_ACCEPT_new(void)
92{
93 BIO_ACCEPT *ret;
94
95 if ((ret = OPENSSL_zalloc(sizeof(*ret))CRYPTO_zalloc(sizeof(*ret), "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 95)
) == NULL((void*)0)) {
96 ERR_raise(ERR_LIB_BIO, ERR_R_MALLOC_FAILURE)(ERR_new(), ERR_set_debug("../deps/openssl/openssl/crypto/bio/bss_acpt.c"
,96,__func__), ERR_set_error)((32),((256|((0x1 << 18L)|
(0x2 << 18L)))),((void*)0))
;
97 return NULL((void*)0);
98 }
99 ret->accept_family = BIO_FAMILY_IPANY256;
100 ret->accept_sock = (int)INVALID_SOCKET(-1);
101 return ret;
102}
103
104static void BIO_ACCEPT_free(BIO_ACCEPT *a)
105{
106 if (a == NULL((void*)0))
107 return;
108 OPENSSL_free(a->param_addr)CRYPTO_free(a->param_addr, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 108)
;
109 OPENSSL_free(a->param_serv)CRYPTO_free(a->param_serv, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 109)
;
110 BIO_ADDRINFO_free(a->addr_first);
111 OPENSSL_free(a->cache_accepting_name)CRYPTO_free(a->cache_accepting_name, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 111)
;
112 OPENSSL_free(a->cache_accepting_serv)CRYPTO_free(a->cache_accepting_serv, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 112)
;
113 OPENSSL_free(a->cache_peer_name)CRYPTO_free(a->cache_peer_name, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 113)
;
114 OPENSSL_free(a->cache_peer_serv)CRYPTO_free(a->cache_peer_serv, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 114)
;
115 BIO_free(a->bio_chain);
116 OPENSSL_free(a)CRYPTO_free(a, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 116)
;
117}
118
119static void acpt_close_socket(BIO *bio)
120{
121 BIO_ACCEPT *c;
122
123 c = (BIO_ACCEPT *)bio->ptr;
124 if (c->accept_sock != (int)INVALID_SOCKET(-1)) {
125 shutdown(c->accept_sock, 2);
126 closesocket(c->accept_sock)close(c->accept_sock);
127 c->accept_sock = (int)INVALID_SOCKET(-1);
128 bio->num = (int)INVALID_SOCKET(-1);
129 }
130}
131
132static int acpt_free(BIO *a)
133{
134 BIO_ACCEPT *data;
135
136 if (a == NULL((void*)0))
137 return 0;
138 data = (BIO_ACCEPT *)a->ptr;
139
140 if (a->shutdown) {
141 acpt_close_socket(a);
142 BIO_ACCEPT_free(data);
143 a->ptr = NULL((void*)0);
144 a->flags = 0;
145 a->init = 0;
146 }
147 return 1;
148}
149
150static int acpt_state(BIO *b, BIO_ACCEPT *c)
151{
152 BIO *bio = NULL((void*)0), *dbio;
153 int s = -1, ret = -1;
154
155 for (;;) {
156 switch (c->state) {
157 case ACPT_S_BEFORE1:
158 if (c->param_addr == NULL((void*)0) && c->param_serv == NULL((void*)0)) {
159 ERR_raise_data(ERR_new(), ERR_set_debug("../deps/openssl/openssl/crypto/bio/bss_acpt.c"
,159,__func__), ERR_set_error)
(ERR_LIB_BIO32,
160 BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED143,
161 "hostname=%s, service=%s",
162 c->param_addr, c->param_serv);
163 goto exit_loop;
164 }
165
166 /* Because we're starting a new bind, any cached name and serv
167 * are now obsolete and need to be cleaned out.
168 * QUESTION: should this be done in acpt_close_socket() instead?
169 */
170 OPENSSL_free(c->cache_accepting_name)CRYPTO_free(c->cache_accepting_name, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 170)
;
171 c->cache_accepting_name = NULL((void*)0);
172 OPENSSL_free(c->cache_accepting_serv)CRYPTO_free(c->cache_accepting_serv, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 172)
;
173 c->cache_accepting_serv = NULL((void*)0);
174 OPENSSL_free(c->cache_peer_name)CRYPTO_free(c->cache_peer_name, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 174)
;
175 c->cache_peer_name = NULL((void*)0);
176 OPENSSL_free(c->cache_peer_serv)CRYPTO_free(c->cache_peer_serv, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 176)
;
177 c->cache_peer_serv = NULL((void*)0);
178
179 c->state = ACPT_S_GET_ADDR2;
180 break;
181
182 case ACPT_S_GET_ADDR2:
183 {
184 int family = AF_UNSPEC0;
185 switch (c->accept_family) {
186 case BIO_FAMILY_IPV66:
187 if (1) { /* This is a trick we use to avoid bit rot.
188 * at least the "else" part will always be
189 * compiled.
190 */
191#ifdef AF_INET610
192 family = AF_INET610;
193 } else {
194#endif
195 ERR_raise(ERR_LIB_BIO, BIO_R_UNAVAILABLE_IP_FAMILY)(ERR_new(), ERR_set_debug("../deps/openssl/openssl/crypto/bio/bss_acpt.c"
,195,__func__), ERR_set_error)((32),(145),((void*)0))
;
196 goto exit_loop;
197 }
198 break;
199 case BIO_FAMILY_IPV44:
200 family = AF_INET2;
201 break;
202 case BIO_FAMILY_IPANY256:
203 family = AF_UNSPEC0;
204 break;
205 default:
206 ERR_raise(ERR_LIB_BIO, BIO_R_UNSUPPORTED_IP_FAMILY)(ERR_new(), ERR_set_debug("../deps/openssl/openssl/crypto/bio/bss_acpt.c"
,206,__func__), ERR_set_error)((32),(146),((void*)0))
;
207 goto exit_loop;
208 }
209 if (BIO_lookup(c->param_addr, c->param_serv, BIO_LOOKUP_SERVER,
210 family, SOCK_STREAMSOCK_STREAM, &c->addr_first) == 0)
211 goto exit_loop;
212 }
213 if (c->addr_first == NULL((void*)0)) {
214 ERR_raise(ERR_LIB_BIO, BIO_R_LOOKUP_RETURNED_NOTHING)(ERR_new(), ERR_set_debug("../deps/openssl/openssl/crypto/bio/bss_acpt.c"
,214,__func__), ERR_set_error)((32),(142),((void*)0))
;
215 goto exit_loop;
216 }
217 c->addr_iter = c->addr_first;
218 c->state = ACPT_S_CREATE_SOCKET3;
219 break;
220
221 case ACPT_S_CREATE_SOCKET3:
222 ERR_set_mark();
223 s = BIO_socket(BIO_ADDRINFO_family(c->addr_iter),
224 BIO_ADDRINFO_socktype(c->addr_iter),
225 BIO_ADDRINFO_protocol(c->addr_iter), 0);
226 if (s == (int)INVALID_SOCKET(-1)) {
227 if ((c->addr_iter = BIO_ADDRINFO_next(c->addr_iter)) != NULL((void*)0)) {
228 /*
229 * if there are more addresses to try, do that first
230 */
231 ERR_pop_to_mark();
232 break;
233 }
234 ERR_clear_last_mark();
235 ERR_raise_data(ERR_new(), ERR_set_debug("../deps/openssl/openssl/crypto/bio/bss_acpt.c"
,235,__func__), ERR_set_error)
(ERR_LIB_SYS2, get_last_socket_error()(*__errno_location ()),
236 "calling socket(%s, %s)",
237 c->param_addr, c->param_serv);
238 ERR_raise(ERR_LIB_BIO, BIO_R_UNABLE_TO_CREATE_SOCKET)(ERR_new(), ERR_set_debug("../deps/openssl/openssl/crypto/bio/bss_acpt.c"
,238,__func__), ERR_set_error)((32),(118),((void*)0))
;
239 goto exit_loop;
240 }
241 c->accept_sock = s;
242 b->num = s;
243 c->state = ACPT_S_LISTEN4;
244 s = -1;
245 break;
246
247 case ACPT_S_LISTEN4:
248 {
249 if (!BIO_listen(c->accept_sock,
250 BIO_ADDRINFO_address(c->addr_iter),
251 c->bind_mode)) {
252 BIO_closesocket(c->accept_sock);
253 goto exit_loop;
254 }
255 }
256
257 {
258 union BIO_sock_info_u info;
259
260 info.addr = &c->cache_accepting_addr;
261 if (!BIO_sock_info(c->accept_sock, BIO_SOCK_INFO_ADDRESS,
262 &info)) {
263 BIO_closesocket(c->accept_sock);
264 goto exit_loop;
265 }
266 }
267
268 c->cache_accepting_name =
269 BIO_ADDR_hostname_string(&c->cache_accepting_addr, 1);
270 c->cache_accepting_serv =
271 BIO_ADDR_service_string(&c->cache_accepting_addr, 1);
272 c->state = ACPT_S_ACCEPT5;
273 s = -1;
Value stored to 's' is never read
274 ret = 1;
275 goto end;
276
277 case ACPT_S_ACCEPT5:
278 if (b->next_bio != NULL((void*)0)) {
279 c->state = ACPT_S_OK6;
280 break;
281 }
282 BIO_clear_retry_flags(b)BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08));
283 b->retry_reason = 0;
284
285 OPENSSL_free(c->cache_peer_name)CRYPTO_free(c->cache_peer_name, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 285)
;
286 c->cache_peer_name = NULL((void*)0);
287 OPENSSL_free(c->cache_peer_serv)CRYPTO_free(c->cache_peer_serv, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 287)
;
288 c->cache_peer_serv = NULL((void*)0);
289
290 s = BIO_accept_ex(c->accept_sock, &c->cache_peer_addr,
291 c->accepted_mode);
292
293 /* If the returned socket is invalid, this might still be
294 * retryable
295 */
296 if (s < 0) {
297 if (BIO_sock_should_retry(s)) {
298 BIO_set_retry_special(b)BIO_set_flags(b, (0x04|0x08));
299 b->retry_reason = BIO_RR_ACCEPT0x03;
300 goto end;
301 }
302 }
303
304 /* If it wasn't retryable, we fail */
305 if (s < 0) {
306 ret = s;
307 goto exit_loop;
308 }
309
310 bio = BIO_new_socket(s, BIO_CLOSE0x01);
311 if (bio == NULL((void*)0))
312 goto exit_loop;
313
314 BIO_set_callback_ex(bio, BIO_get_callback_ex(b));
315#ifndef OPENSSL_NO_DEPRECATED_3_0
316 BIO_set_callback(bio, BIO_get_callback(b));
317#endif
318 BIO_set_callback_arg(bio, BIO_get_callback_arg(b));
319 /*
320 * If the accept BIO has an bio_chain, we dup it and put the new
321 * socket at the end.
322 */
323 if (c->bio_chain != NULL((void*)0)) {
324 if ((dbio = BIO_dup_chain(c->bio_chain)) == NULL((void*)0))
325 goto exit_loop;
326 if (!BIO_push(dbio, bio))
327 goto exit_loop;
328 bio = dbio;
329 }
330 if (BIO_push(b, bio) == NULL((void*)0))
331 goto exit_loop;
332
333 c->cache_peer_name =
334 BIO_ADDR_hostname_string(&c->cache_peer_addr, 1);
335 c->cache_peer_serv =
336 BIO_ADDR_service_string(&c->cache_peer_addr, 1);
337 c->state = ACPT_S_OK6;
338 bio = NULL((void*)0);
339 ret = 1;
340 goto end;
341
342 case ACPT_S_OK6:
343 if (b->next_bio == NULL((void*)0)) {
344 c->state = ACPT_S_ACCEPT5;
345 break;
346 }
347 ret = 1;
348 goto end;
349
350 default:
351 ret = 0;
352 goto end;
353 }
354 }
355
356 exit_loop:
357 if (bio != NULL((void*)0))
358 BIO_free(bio);
359 else if (s >= 0)
360 BIO_closesocket(s);
361 end:
362 return ret;
363}
364
365static int acpt_read(BIO *b, char *out, int outl)
366{
367 int ret = 0;
368 BIO_ACCEPT *data;
369
370 BIO_clear_retry_flags(b)BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08));
371 data = (BIO_ACCEPT *)b->ptr;
372
373 while (b->next_bio == NULL((void*)0)) {
374 ret = acpt_state(b, data);
375 if (ret <= 0)
376 return ret;
377 }
378
379 ret = BIO_read(b->next_bio, out, outl);
380 BIO_copy_next_retry(b);
381 return ret;
382}
383
384static int acpt_write(BIO *b, const char *in, int inl)
385{
386 int ret;
387 BIO_ACCEPT *data;
388
389 BIO_clear_retry_flags(b)BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08));
390 data = (BIO_ACCEPT *)b->ptr;
391
392 while (b->next_bio == NULL((void*)0)) {
393 ret = acpt_state(b, data);
394 if (ret <= 0)
395 return ret;
396 }
397
398 ret = BIO_write(b->next_bio, in, inl);
399 BIO_copy_next_retry(b);
400 return ret;
401}
402
403static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
404{
405 int *ip;
406 long ret = 1;
407 BIO_ACCEPT *data;
408 char **pp;
409
410 data = (BIO_ACCEPT *)b->ptr;
411
412 switch (cmd) {
413 case BIO_CTRL_RESET1:
414 ret = 0;
415 data->state = ACPT_S_BEFORE1;
416 acpt_close_socket(b);
417 BIO_ADDRINFO_free(data->addr_first);
418 data->addr_first = NULL((void*)0);
419 b->flags = 0;
420 break;
421 case BIO_C_DO_STATE_MACHINE101:
422 /* use this one to start the connection */
423 ret = (long)acpt_state(b, data);
424 break;
425 case BIO_C_SET_ACCEPT118:
426 if (ptr != NULL((void*)0)) {
427 if (num == 0) {
428 char *hold_serv = data->param_serv;
429 /* We affect the hostname regardless. However, the input
430 * string might contain a host:service spec, so we must
431 * parse it, which might or might not affect the service
432 */
433 OPENSSL_free(data->param_addr)CRYPTO_free(data->param_addr, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 433)
;
434 data->param_addr = NULL((void*)0);
435 ret = BIO_parse_hostserv(ptr,
436 &data->param_addr,
437 &data->param_serv,
438 BIO_PARSE_PRIO_SERV);
439 if (hold_serv != data->param_serv)
440 OPENSSL_free(hold_serv)CRYPTO_free(hold_serv, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 440)
;
441 b->init = 1;
442 } else if (num == 1) {
443 OPENSSL_free(data->param_serv)CRYPTO_free(data->param_serv, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 443)
;
444 if ((data->param_serv = OPENSSL_strdup(ptr)CRYPTO_strdup(ptr, "../deps/openssl/openssl/crypto/bio/bss_acpt.c"
, 444)
) == NULL((void*)0))
445 ret = 0;
446 else
447 b->init = 1;
448 } else if (num == 2) {
449 data->bind_mode |= BIO_SOCK_NONBLOCK0x08;
450 } else if (num == 3) {
451 BIO_free(data->bio_chain);
452 data->bio_chain = (BIO *)ptr;
453 } else if (num == 4) {
454 data->accept_family = *(int *)ptr;
455 }
456 } else {
457 if (num == 2) {
458 data->bind_mode &= ~BIO_SOCK_NONBLOCK0x08;
459 }
460 }
461 break;
462 case BIO_C_SET_NBIO102:
463 if (num != 0)
464 data->accepted_mode |= BIO_SOCK_NONBLOCK0x08;
465 else
466 data->accepted_mode &= ~BIO_SOCK_NONBLOCK0x08;
467 break;
468 case BIO_C_SET_FD104:
469 b->num = *((int *)ptr);
470 data->accept_sock = b->num;
471 data->state = ACPT_S_ACCEPT5;
472 b->shutdown = (int)num;
473 b->init = 1;
474 break;
475 case BIO_C_GET_FD105:
476 if (b->init) {
477 ip = (int *)ptr;
478 if (ip != NULL((void*)0))
479 *ip = data->accept_sock;
480 ret = data->accept_sock;
481 } else
482 ret = -1;
483 break;
484 case BIO_C_GET_ACCEPT124:
485 if (b->init) {
486 if (num == 0 && ptr != NULL((void*)0)) {
487 pp = (char **)ptr;
488 *pp = data->cache_accepting_name;
489 } else if (num == 1 && ptr != NULL((void*)0)) {
490 pp = (char **)ptr;
491 *pp = data->cache_accepting_serv;
492 } else if (num == 2 && ptr != NULL((void*)0)) {
493 pp = (char **)ptr;
494 *pp = data->cache_peer_name;
495 } else if (num == 3 && ptr != NULL((void*)0)) {
496 pp = (char **)ptr;
497 *pp = data->cache_peer_serv;
498 } else if (num == 4) {
499 switch (BIO_ADDRINFO_family(data->addr_iter)) {
500#ifdef AF_INET610
501 case AF_INET610:
502 ret = BIO_FAMILY_IPV66;
503 break;
504#endif
505 case AF_INET2:
506 ret = BIO_FAMILY_IPV44;
507 break;
508 case 0:
509 ret = data->accept_family;
510 break;
511 default:
512 ret = -1;
513 break;
514 }
515 } else
516 ret = -1;
517 } else
518 ret = -1;
519 break;
520 case BIO_CTRL_GET_CLOSE8:
521 ret = b->shutdown;
522 break;
523 case BIO_CTRL_SET_CLOSE9:
524 b->shutdown = (int)num;
525 break;
526 case BIO_CTRL_PENDING10:
527 case BIO_CTRL_WPENDING13:
528 ret = 0;
529 break;
530 case BIO_CTRL_FLUSH11:
531 break;
532 case BIO_C_SET_BIND_MODE131:
533 data->bind_mode = (int)num;
534 break;
535 case BIO_C_GET_BIND_MODE132:
536 ret = (long)data->bind_mode;
537 break;
538 case BIO_CTRL_DUP12:
539 break;
540 case BIO_CTRL_EOF2:
541 if (b->next_bio == NULL((void*)0))
542 ret = 0;
543 else
544 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
545 break;
546 default:
547 ret = 0;
548 break;
549 }
550 return ret;
551}
552
553static int acpt_puts(BIO *bp, const char *str)
554{
555 int n, ret;
556
557 n = strlen(str);
558 ret = acpt_write(bp, str, n);
559 return ret;
560}
561
562BIO *BIO_new_accept(const char *str)
563{
564 BIO *ret;
565
566 ret = BIO_new(BIO_s_accept());
567 if (ret == NULL((void*)0))
568 return NULL((void*)0);
569 if (BIO_set_accept_name(ret, str)BIO_ctrl(ret,118,0, (char *)(str)))
570 return ret;
571 BIO_free(ret);
572 return NULL((void*)0);
573}
574
575#endif