Check-in [2893572aa6]
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 on 2017-05-01 14:32:40
Other Links: manifest | tags
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

Modified tls.c from [57028b60c1] to [325d38b6f1].

622
623
624
625
626
627
628
629
630
631
632
633
634

635
636
637
638
639





640
641

642
643
644
645
646




647
648
649
650
651




652
653
654
655
656
657
658






659
660
661
662



663
664

665
666

667
668
669
670
671
672
673






674
675
676
677
678



679
680
681
682



683
684
685
686



687
688
689


690
691
692
693




694
695
696

697
698
699
700
701
702
703
622
623
624
625
626
627
628






629





630
631
632
633
634
635

636
637




638
639
640
641
642




643
644
645
646
647






648
649
650
651
652
653




654
655
656
657

658
659

660
661






662
663
664
665
666
667
668
669



670
671
672
673



674
675
676
677



678
679
680
681


682
683
684



685
686
687
688
689
690

691
692
693
694
695
696
697
698







-
-
-
-
-
-
+
-
-
-
-
-
+
+
+
+
+

-
+

-
-
-
-
+
+
+
+

-
-
-
-
+
+
+
+

-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+

-
+

-
+

-
-
-
-
-
-
+
+
+
+
+
+


-
-
-
+
+
+

-
-
-
+
+
+

-
-
-
+
+
+

-
-
+
+

-
-
-
+
+
+
+


-
+







 *
 * Side effects:
 *	May force SSL negotiation to take place.
 *
 *-------------------------------------------------------------------
 */

static int
HandshakeObjCmd(clientData, interp, objc, objv)
    ClientData clientData;	/* Not used. */
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *CONST objv[];
static int HandshakeObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
{
    Tcl_Channel chan;		/* The channel to set a mode on. */
    State *statePtr;		/* client state for ssl socket */
    int ret = 1;
    int err = 0;
	Tcl_Channel chan;		/* The channel to set a mode on. */
	State *statePtr;		/* client state for ssl socket */
	CONST char *errStr = NULL;
	int ret = 1;
	int err = 0;

    dprintf("Called");
	dprintf("Called");

    if (objc != 2) {
	Tcl_WrongNumArgs(interp, 1, objv, "channel");
	return TCL_ERROR;
    }
	if (objc != 2) {
		Tcl_WrongNumArgs(interp, 1, objv, "channel");
		return(TCL_ERROR);
	}

    chan = Tcl_GetChannel(interp, Tcl_GetStringFromObj(objv[1], NULL), NULL);
    if (chan == (Tcl_Channel) NULL) {
	return TCL_ERROR;
    }
	chan = Tcl_GetChannel(interp, Tcl_GetStringFromObj(objv[1], NULL), NULL);
	if (chan == (Tcl_Channel) NULL) {
		return(TCL_ERROR);
	}

    /*
     * Make sure to operate on the topmost channel
     */
    chan = Tcl_GetTopChannel(chan);
    if (Tcl_GetChannelType(chan) != Tls_ChannelType()) {
	Tcl_AppendResult(interp, "bad channel \"", Tcl_GetChannelName(chan),
	/*
	 * Make sure to operate on the topmost channel
	 */
	chan = Tcl_GetTopChannel(chan);
	if (Tcl_GetChannelType(chan) != Tls_ChannelType()) {
		Tcl_AppendResult(interp, "bad channel \"", Tcl_GetChannelName(chan), "\": not a TLS channel", NULL);
		"\": not a TLS channel", NULL);
	return TCL_ERROR;
    }
    statePtr = (State *)Tcl_GetChannelInstanceData(chan);
		return(TCL_ERROR);
	}
	statePtr = (State *)Tcl_GetChannelInstanceData(chan);

        dprintf("Calling Tls_WaitForConnect");
	dprintf("Calling Tls_WaitForConnect");
	ret = Tls_WaitForConnect(statePtr, &err, 1);
        dprintf("Tls_WaitForConnect returned: %i", ret);
	dprintf("Tls_WaitForConnect returned: %i", ret);

     if (ret < 0) {
	if ((statePtr->flags & TLS_TCL_ASYNC) && err == EAGAIN) {
            dprintf("Async set and err = EAGAIN");
	    ret = 0;
	}
     }
	if (ret < 0) {
		if ((statePtr->flags & TLS_TCL_ASYNC) && err == EAGAIN) {
			dprintf("Async set and err = EAGAIN");
			ret = 0;
		}
	}

	if (ret < 0) {
	    CONST char *errStr = statePtr->err;
	    Tcl_ResetResult(interp);
	    Tcl_SetErrno(err);
		errStr = statePtr->err;
		Tcl_ResetResult(interp);
		Tcl_SetErrno(err);

	    if (!errStr || *errStr == 0) {
		errStr = Tcl_PosixError(interp);
	    }
		if (!errStr || *errStr == 0) {
			errStr = Tcl_PosixError(interp);
		}

	    Tcl_AppendResult(interp, "handshake failed: ", errStr, (char *) NULL);
            dprintf("Returning TCL_ERROR with handshake failed: %s", errStr);
	    return TCL_ERROR;
		Tcl_AppendResult(interp, "handshake failed: ", errStr, (char *) NULL);
		dprintf("Returning TCL_ERROR with handshake failed: %s", errStr);
		return(TCL_ERROR);
	} else {
          ret = 1;
        }
		ret = 1;
	}

    dprintf("Returning TCL_OK with data \"%i\"", ret);
    Tcl_SetObjResult(interp, Tcl_NewIntObj(ret));
    return TCL_OK;
	dprintf("Returning TCL_OK with data \"%i\"", ret);
	Tcl_SetObjResult(interp, Tcl_NewIntObj(ret));
	return(TCL_OK);

    	clientData = clientData;
}


/*
 *-------------------------------------------------------------------
 *
 * ImportObjCmd --
 *
 *	This procedure is invoked to process the "ssl" command
 *