| @@ -417,27 +417,26 @@ static int ndoit(SSL_CTX *ssl_ctx[2]) | | | @@ -417,27 +417,26 @@ static int ndoit(SSL_CTX *ssl_ctx[2]) |
417 | } | | 417 | } |
418 | | | 418 | |
419 | int doit(char *ctx[4]) | | 419 | int doit(char *ctx[4]) |
420 | { | | 420 | { |
421 | SSL_CTX *s_ctx,*c_ctx; | | 421 | SSL_CTX *s_ctx,*c_ctx; |
422 | static char cbuf[200],sbuf[200]; | | 422 | static char cbuf[200],sbuf[200]; |
423 | SSL *c_ssl=NULL; | | 423 | SSL *c_ssl=NULL; |
424 | SSL *s_ssl=NULL; | | 424 | SSL *s_ssl=NULL; |
425 | BIO *c_to_s=NULL; | | 425 | BIO *c_to_s=NULL; |
426 | BIO *s_to_c=NULL; | | 426 | BIO *s_to_c=NULL; |
427 | BIO *c_bio=NULL; | | 427 | BIO *c_bio=NULL; |
428 | BIO *s_bio=NULL; | | 428 | BIO *s_bio=NULL; |
429 | int c_r,c_w,s_r,s_w; | | 429 | int c_r,c_w,s_r,s_w; |
430 | int c_want,s_want; | | | |
431 | int i; | | 430 | int i; |
432 | int done=0; | | 431 | int done=0; |
433 | int c_write,s_write; | | 432 | int c_write,s_write; |
434 | int do_server=0,do_client=0; | | 433 | int do_server=0,do_client=0; |
435 | | | 434 | |
436 | s_ctx=(SSL_CTX *)ctx[0]; | | 435 | s_ctx=(SSL_CTX *)ctx[0]; |
437 | c_ctx=(SSL_CTX *)ctx[1]; | | 436 | c_ctx=(SSL_CTX *)ctx[1]; |
438 | | | 437 | |
439 | if (ctx[2] != NULL) | | 438 | if (ctx[2] != NULL) |
440 | s_ssl=(SSL *)ctx[2]; | | 439 | s_ssl=(SSL *)ctx[2]; |
441 | else | | 440 | else |
442 | s_ssl=SSL_new(s_ctx); | | 441 | s_ssl=SSL_new(s_ctx); |
443 | | | 442 | |
| @@ -456,28 +455,26 @@ int doit(char *ctx[4]) | | | @@ -456,28 +455,26 @@ int doit(char *ctx[4]) |
456 | s_bio=BIO_new(BIO_f_ssl()); | | 455 | s_bio=BIO_new(BIO_f_ssl()); |
457 | if ((c_bio == NULL) || (s_bio == NULL)) goto err; | | 456 | if ((c_bio == NULL) || (s_bio == NULL)) goto err; |
458 | | | 457 | |
459 | SSL_set_connect_state(c_ssl); | | 458 | SSL_set_connect_state(c_ssl); |
460 | SSL_set_bio(c_ssl,s_to_c,c_to_s); | | 459 | SSL_set_bio(c_ssl,s_to_c,c_to_s); |
461 | BIO_set_ssl(c_bio,c_ssl,(ctx[2] == NULL)?BIO_CLOSE:BIO_NOCLOSE); | | 460 | BIO_set_ssl(c_bio,c_ssl,(ctx[2] == NULL)?BIO_CLOSE:BIO_NOCLOSE); |
462 | | | 461 | |
463 | SSL_set_accept_state(s_ssl); | | 462 | SSL_set_accept_state(s_ssl); |
464 | SSL_set_bio(s_ssl,c_to_s,s_to_c); | | 463 | SSL_set_bio(s_ssl,c_to_s,s_to_c); |
465 | BIO_set_ssl(s_bio,s_ssl,(ctx[3] == NULL)?BIO_CLOSE:BIO_NOCLOSE); | | 464 | BIO_set_ssl(s_bio,s_ssl,(ctx[3] == NULL)?BIO_CLOSE:BIO_NOCLOSE); |
466 | | | 465 | |
467 | c_r=0; s_r=1; | | 466 | c_r=0; s_r=1; |
468 | c_w=1; s_w=0; | | 467 | c_w=1; s_w=0; |
469 | c_want=W_WRITE; | | | |
470 | s_want=0; | | | |
471 | c_write=1,s_write=0; | | 468 | c_write=1,s_write=0; |
472 | | | 469 | |
473 | /* We can always do writes */ | | 470 | /* We can always do writes */ |
474 | for (;;) | | 471 | for (;;) |
475 | { | | 472 | { |
476 | do_server=0; | | 473 | do_server=0; |
477 | do_client=0; | | 474 | do_client=0; |
478 | | | 475 | |
479 | i=(int)BIO_pending(s_bio); | | 476 | i=(int)BIO_pending(s_bio); |
480 | if ((i && s_r) || s_w) do_server=1; | | 477 | if ((i && s_r) || s_w) do_server=1; |
481 | | | 478 | |
482 | i=(int)BIO_pending(c_bio); | | 479 | i=(int)BIO_pending(c_bio); |
483 | if ((i && c_r) || c_w) do_client=1; | | 480 | if ((i && c_r) || c_w) do_client=1; |