Overview
Comment: | Code formatting. TlsCloseProc is no longer needed in Tcl 9. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | nijtmans |
Files: | files | file ages | folders |
SHA3-256: |
2382e3457df0f6cc48f5c99060d8c3b0 |
User & Date: | jan.nijtmans on 2024-02-23 09:13:27 |
Other Links: | branch diff | manifest | tags |
Context
2024-02-23
| ||
10:19 | Fix ciphers.test testcases for OpenSSL 3.0. Remove files no longer needed check-in: b8d4646795 user: jan.nijtmans tags: nijtmans | |
09:39 | Merge trunk check-in: a288c8e1e1 user: jan.nijtmans tags: bohagan | |
09:13 | Code formatting. TlsCloseProc is no longer needed in Tcl 9. check-in: 2382e3457d user: jan.nijtmans tags: nijtmans | |
2024-02-22
| ||
20:02 | No need to define Tcl_Size in tlsInt.h: already handled by TEA check-in: a66c2b01b1 user: jan.nijtmans tags: nijtmans | |
Changes
Modified generic/tlsIO.c
from [46ff3e28a8]
to [f0f140b4c0].
︙ | ︙ | |||
50 51 52 53 54 55 56 | } return(0); } /* *------------------------------------------------------------------- * | | > > > | > > > > > | | > > | | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | } return(0); } /* *------------------------------------------------------------------- * * TlsClose2Proc -- * * This procedure is invoked by the generic IO level to perform * channel-type-specific cleanup when a SSL socket based channel * is closed. * * Note: we leave the underlying socket alone, is this right? * * Results: * 0 if successful or POSIX error code if failed. * * Side effects: * Closes the socket of the channel. * *------------------------------------------------------------------- */ #if TCL_MAJOR_VERSION > 8 # define TlsCloseProc NULL /* No longer neccessary in Tcl 9 */ #else static int TlsCloseProc( void *instanceData, TCL_UNUSED(Tcl_Interp *)) { State *statePtr = (State *)instanceData; dprintf("TlsCloseProc(%p)", statePtr); Tls_Clean(statePtr); Tcl_EventuallyFree(statePtr, Tls_Free); return TCL_OK; } #endif static int TlsClose2Proc( void *instanceData, /* The socket state. */ Tcl_Interp *interp, /* For errors - can be NULL. */ int flags) /* Flags to close read and/or write side of channel */ { State *statePtr = (State *)instanceData; dprintf("TlsClose2Proc(%p)", statePtr); if ((flags&(TCL_CLOSE_READ|TCL_CLOSE_WRITE))) { return EINVAL; } Tls_Clean(statePtr); Tcl_EventuallyFree(statePtr, Tls_Free); return TCL_OK; } /* *------------------------------------------------------* * * Tls_WaitForConnect -- * |
︙ | ︙ | |||
136 137 138 139 140 141 142 | return(-1); } for (;;) { /* Not initialized yet! */ if (statePtr->flags & TLS_TCL_SERVER) { dprintf("Calling SSL_accept()"); | < | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | return(-1); } for (;;) { /* Not initialized yet! */ if (statePtr->flags & TLS_TCL_SERVER) { dprintf("Calling SSL_accept()"); err = SSL_accept(statePtr->ssl); } else { dprintf("Calling SSL_connect()"); err = SSL_connect(statePtr->ssl); } if (err > 0) { dprintf("That seems to have gone okay"); |
︙ | ︙ | |||
221 222 223 224 225 226 227 | if (*errorCodePtr == ECONNRESET) { *errorCodePtr = ECONNABORTED; } } statePtr->flags |= TLS_TCL_HANDSHAKE_FAILED; | | | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | if (*errorCodePtr == ECONNRESET) { *errorCodePtr = ECONNABORTED; } } statePtr->flags |= TLS_TCL_HANDSHAKE_FAILED; return -1; case SSL_ERROR_SSL: dprintf("Got permanent fatal SSL error, aborting immediately"); Tls_Error(statePtr, (char *)ERR_reason_error_string(ERR_get_error())); statePtr->flags |= TLS_TCL_HANDSHAKE_FAILED; *errorCodePtr = ECONNABORTED; return(-1); case SSL_ERROR_WANT_CONNECT: |
︙ | ︙ | |||
528 529 530 531 532 533 534 | break; case SSL_ERROR_SSL: Tls_Error(statePtr, TCLTLS_SSL_ERROR(statePtr->ssl, written)); *errorCodePtr = ECONNABORTED; written = -1; break; default: | | | 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | break; case SSL_ERROR_SSL: Tls_Error(statePtr, TCLTLS_SSL_ERROR(statePtr->ssl, written)); *errorCodePtr = ECONNABORTED; written = -1; break; default: dprintf("unknown error: %d", err); break; } dprintf("Output(%d) -> %d", toWrite, written); return(written); } |
︙ | ︙ | |||
560 561 562 563 564 565 566 | */ static int TlsGetOptionProc( void *instanceData, /* Socket state. */ Tcl_Interp *interp, /* For errors - can be NULL. */ const char *optionName, /* Name of the option to retrieve the value for, or * NULL to get all options and their values. */ | | | | 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | */ static int TlsGetOptionProc( void *instanceData, /* Socket state. */ Tcl_Interp *interp, /* For errors - can be NULL. */ const char *optionName, /* Name of the option to retrieve the value for, or * NULL to get all options and their values. */ Tcl_DString *optionValue) /* Where to store the computed value initialized by caller. */ { State *statePtr = (State *) instanceData; Tcl_Channel downChan = Tls_GetParent(statePtr, TLS_TCL_FASTPATH); Tcl_DriverGetOptionProc *getOptionProc; getOptionProc = Tcl_ChannelGetOptionProc(Tcl_GetChannelType(downChan)); if (getOptionProc != NULL) { return (*getOptionProc)(Tcl_GetChannelInstanceData(downChan), interp, optionName, optionValue); } else if (optionName == (char*) NULL) { /* * Request is query for all options, this is ok. */ return TCL_OK; } /* |
︙ | ︙ | |||
753 754 755 756 757 758 759 | } dprintf("Returning %i", mask); return(mask); } | < | | | < | | | < | | | < | < < < < | > | < < | < < | > > | < < < < | < > | < < < < < < < < < < < < < | | | | | < < < < < < | > | | > > | | < < < | < < < < < < < < < < < < < < | | 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | } dprintf("Returning %i", mask); return(mask); } /* *------------------------------------------------------* * * TlsChannelHandlerTimer -- * * ------------------------------------------------* * Called by the notifier (-> timer) to flush out * information waiting in channel buffers. * ------------------------------------------------* * * Side effects: * As of 'TlsChannelHandler'. * * Result: * None. * *------------------------------------------------------* */ static void TlsChannelHandlerTimer(void *clientData) { State *statePtr = (State *)clientData; int mask = 0; dprintf("Called"); statePtr->timer = (Tcl_TimerToken) NULL; if (BIO_wpending(statePtr->bio)) { dprintf("[chan=%p] BIO writable", statePtr->self); mask |= TCL_WRITABLE; } if (BIO_pending(statePtr->bio)) { dprintf("[chan=%p] BIO readable", statePtr->self); mask |= TCL_READABLE; } dprintf("Notifying ourselves"); Tcl_NotifyChannel(statePtr->self, mask); dprintf("Returning"); return; } Tcl_Channel Tls_GetParent(State *statePtr, int maskFlags) { dprintf("Requested to get parent of channel %p", statePtr->self); if ((statePtr->flags & ~maskFlags) & TLS_TCL_FASTPATH) { dprintf("Asked to get the parent channel while we are using FastPath -- returning NULL"); return(NULL); } return Tcl_GetStackedChannel(statePtr->self); } /* *------------------------------------------------------------------- * * Tls_ChannelType -- * * Return the correct TLS channel driver info |
︙ | ︙ | |||
893 894 895 896 897 898 899 | NULL, /* Thread action */ NULL /* Truncate */ }; const Tcl_ChannelType *Tls_ChannelType(void) { return &tlsChannelType; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 856 857 858 859 860 861 862 | NULL, /* Thread action */ NULL /* Truncate */ }; const Tcl_ChannelType *Tls_ChannelType(void) { return &tlsChannelType; } |