Check-in [2893572aa6]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Reformatted handshake command code
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2893572aa62cab34a41d6e8bfd579a8dd6f84266
User & Date: rkeene 2017-05-01 14:32:40
Context
2017-05-01
14:41
Fixed an issue where EAGAIN was translated into a successful handshake, addressing [1367823d51] check-in: 689d55e070 user: rkeene tags: trunk
14:32
Reformatted handshake command code check-in: 2893572aa6 user: rkeene tags: trunk
2017-04-18
18:31
Added support for a configure option to specify the built-in DH params size called "--with-builtin-dh-params-size" check-in: 5e7de567cf user: rkeene tags: trunk
Changes

Changes to tls.c.

   622    622    *
   623    623    * Side effects:
   624    624    *	May force SSL negotiation to take place.
   625    625    *
   626    626    *-------------------------------------------------------------------
   627    627    */
   628    628   
   629         -static int
   630         -HandshakeObjCmd(clientData, interp, objc, objv)
   631         -    ClientData clientData;	/* Not used. */
   632         -    Tcl_Interp *interp;
   633         -    int objc;
   634         -    Tcl_Obj *CONST objv[];
   635         -{
   636         -    Tcl_Channel chan;		/* The channel to set a mode on. */
   637         -    State *statePtr;		/* client state for ssl socket */
   638         -    int ret = 1;
   639         -    int err = 0;
   640         -
   641         -    dprintf("Called");
   642         -
   643         -    if (objc != 2) {
   644         -	Tcl_WrongNumArgs(interp, 1, objv, "channel");
   645         -	return TCL_ERROR;
   646         -    }
   647         -
   648         -    chan = Tcl_GetChannel(interp, Tcl_GetStringFromObj(objv[1], NULL), NULL);
   649         -    if (chan == (Tcl_Channel) NULL) {
   650         -	return TCL_ERROR;
   651         -    }
   652         -
   653         -    /*
   654         -     * Make sure to operate on the topmost channel
   655         -     */
   656         -    chan = Tcl_GetTopChannel(chan);
   657         -    if (Tcl_GetChannelType(chan) != Tls_ChannelType()) {
   658         -	Tcl_AppendResult(interp, "bad channel \"", Tcl_GetChannelName(chan),
   659         -		"\": not a TLS channel", NULL);
   660         -	return TCL_ERROR;
   661         -    }
   662         -    statePtr = (State *)Tcl_GetChannelInstanceData(chan);
   663         -
   664         -        dprintf("Calling Tls_WaitForConnect");
          629  +static int HandshakeObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
          630  +	Tcl_Channel chan;		/* The channel to set a mode on. */
          631  +	State *statePtr;		/* client state for ssl socket */
          632  +	CONST char *errStr = NULL;
          633  +	int ret = 1;
          634  +	int err = 0;
          635  +
          636  +	dprintf("Called");
          637  +
          638  +	if (objc != 2) {
          639  +		Tcl_WrongNumArgs(interp, 1, objv, "channel");
          640  +		return(TCL_ERROR);
          641  +	}
          642  +
          643  +	chan = Tcl_GetChannel(interp, Tcl_GetStringFromObj(objv[1], NULL), NULL);
          644  +	if (chan == (Tcl_Channel) NULL) {
          645  +		return(TCL_ERROR);
          646  +	}
          647  +
          648  +	/*
          649  +	 * Make sure to operate on the topmost channel
          650  +	 */
          651  +	chan = Tcl_GetTopChannel(chan);
          652  +	if (Tcl_GetChannelType(chan) != Tls_ChannelType()) {
          653  +		Tcl_AppendResult(interp, "bad channel \"", Tcl_GetChannelName(chan), "\": not a TLS channel", NULL);
          654  +		return(TCL_ERROR);
          655  +	}
          656  +	statePtr = (State *)Tcl_GetChannelInstanceData(chan);
          657  +
          658  +	dprintf("Calling Tls_WaitForConnect");
   665    659   	ret = Tls_WaitForConnect(statePtr, &err, 1);
   666         -        dprintf("Tls_WaitForConnect returned: %i", ret);
          660  +	dprintf("Tls_WaitForConnect returned: %i", ret);
   667    661   
   668         -     if (ret < 0) {
   669         -	if ((statePtr->flags & TLS_TCL_ASYNC) && err == EAGAIN) {
   670         -            dprintf("Async set and err = EAGAIN");
   671         -	    ret = 0;
          662  +	if (ret < 0) {
          663  +		if ((statePtr->flags & TLS_TCL_ASYNC) && err == EAGAIN) {
          664  +			dprintf("Async set and err = EAGAIN");
          665  +			ret = 0;
          666  +		}
   672    667   	}
   673         -     }
   674    668   
   675    669   	if (ret < 0) {
   676         -	    CONST char *errStr = statePtr->err;
   677         -	    Tcl_ResetResult(interp);
   678         -	    Tcl_SetErrno(err);
          670  +		errStr = statePtr->err;
          671  +		Tcl_ResetResult(interp);
          672  +		Tcl_SetErrno(err);
   679    673   
   680         -	    if (!errStr || *errStr == 0) {
   681         -		errStr = Tcl_PosixError(interp);
   682         -	    }
          674  +		if (!errStr || *errStr == 0) {
          675  +			errStr = Tcl_PosixError(interp);
          676  +		}
   683    677   
   684         -	    Tcl_AppendResult(interp, "handshake failed: ", errStr, (char *) NULL);
   685         -            dprintf("Returning TCL_ERROR with handshake failed: %s", errStr);
   686         -	    return TCL_ERROR;
          678  +		Tcl_AppendResult(interp, "handshake failed: ", errStr, (char *) NULL);
          679  +		dprintf("Returning TCL_ERROR with handshake failed: %s", errStr);
          680  +		return(TCL_ERROR);
   687    681   	} else {
   688         -          ret = 1;
   689         -        }
          682  +		ret = 1;
          683  +	}
   690    684   
   691         -    dprintf("Returning TCL_OK with data \"%i\"", ret);
   692         -    Tcl_SetObjResult(interp, Tcl_NewIntObj(ret));
   693         -    return TCL_OK;
          685  +	dprintf("Returning TCL_OK with data \"%i\"", ret);
          686  +	Tcl_SetObjResult(interp, Tcl_NewIntObj(ret));
          687  +	return(TCL_OK);
          688  +
   694    689       	clientData = clientData;
   695    690   }
   696         -
          691  +
   697    692   /*
   698    693    *-------------------------------------------------------------------
   699    694    *
   700    695    * ImportObjCmd --
   701    696    *
   702    697    *	This procedure is invoked to process the "ssl" command
   703    698    *