Diff

Differences From Artifact [b2d6351a90]:

To Artifact [a8f1e9327c]:


247
248
249
250
251
252
253

254
255
256
257
258
259
260
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261







+







	else if (c == '\n')
	    break;
    }

    sprintf(vstring, "SSH-%s-7.7.7\n",
	    (strcmp(version, "1.5") <= 0 ? version : "1.5"));
    s_write(vstring, strlen(vstring));
    return 1;
}

static void ssh_protocol(unsigned char *in, int inlen, int ispkt) {
    int i, j, len;
    unsigned char session_id[16];
    unsigned char *rsabuf, *keystr1, *keystr2;
    unsigned char cookie[8];
429
430
431
432
433
434
435

436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459

























460
461
462
463
464
465
466
430
431
432
433
434
435
436
437
























438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469







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







	if (pktin.type == 15) {
	    c_write("Access denied\r\n", 15);
	} else if (pktin.type != 14) {
	    fatalbox("Strange packet received, type %d", pktin.type);
	}
    }

    if (!cfg.nopty) {
    i = strlen(cfg.termtype);
    s_wrpkt_start(10, i+5*4+1);
    pktout.body[0] = (i >> 24) & 0xFF;
    pktout.body[1] = (i >> 16) & 0xFF;
    pktout.body[2] = (i >> 8) & 0xFF;
    pktout.body[3] = i & 0xFF;
    memcpy(pktout.body+4, cfg.termtype, i);
    i += 4;
    pktout.body[i++] = (rows >> 24) & 0xFF;
    pktout.body[i++] = (rows >> 16) & 0xFF;
    pktout.body[i++] = (rows >> 8) & 0xFF;
    pktout.body[i++] = rows & 0xFF;
    pktout.body[i++] = (cols >> 24) & 0xFF;
    pktout.body[i++] = (cols >> 16) & 0xFF;
    pktout.body[i++] = (cols >> 8) & 0xFF;
    pktout.body[i++] = cols & 0xFF;
    memset(pktout.body+i, 0, 9);       /* 0 pixwidth, 0 pixheight, 0.b endofopt */
    s_wrpkt();
    ssh_state = SSH_STATE_INTERMED;
    do { crReturnV; } while (!ispkt);
    if (pktin.type != 14 && pktin.type != 15) {
	fatalbox("Protocol confusion");
    } else if (pktin.type == 15) {
	c_write("Server refused to allocate pty\r\n", 32);
        i = strlen(cfg.termtype);
        s_wrpkt_start(10, i+5*4+1);
        pktout.body[0] = (i >> 24) & 0xFF;
        pktout.body[1] = (i >> 16) & 0xFF;
        pktout.body[2] = (i >> 8) & 0xFF;
        pktout.body[3] = i & 0xFF;
        memcpy(pktout.body+4, cfg.termtype, i);
        i += 4;
        pktout.body[i++] = (rows >> 24) & 0xFF;
        pktout.body[i++] = (rows >> 16) & 0xFF;
        pktout.body[i++] = (rows >> 8) & 0xFF;
        pktout.body[i++] = rows & 0xFF;
        pktout.body[i++] = (cols >> 24) & 0xFF;
        pktout.body[i++] = (cols >> 16) & 0xFF;
        pktout.body[i++] = (cols >> 8) & 0xFF;
        pktout.body[i++] = cols & 0xFF;
        memset(pktout.body+i, 0, 9);       /* 0 pixwidth, 0 pixheight, 0.b endofopt */
        s_wrpkt();
        ssh_state = SSH_STATE_INTERMED;
        do { crReturnV; } while (!ispkt);
        if (pktin.type != 14 && pktin.type != 15) {
            fatalbox("Protocol confusion");
        } else if (pktin.type == 15) {
            c_write("Server refused to allocate pty\r\n", 32);
        }
    }

    s_wrpkt_start(12, 0);
    s_wrpkt();

    ssh_state = SSH_STATE_SESSION;
    if (size_needed)
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
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







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







    switch (ssh_state) {
      case SSH_STATE_BEFORE_SIZE:
	break;			       /* do nothing */
      case SSH_STATE_INTERMED:
	size_needed = TRUE;	       /* buffer for later */
	break;
      case SSH_STATE_SESSION:
        if (!cfg.nopty) {
	s_wrpkt_start(11, 16);
	pktout.body[0] = (rows >> 24) & 0xFF;
	pktout.body[1] = (rows >> 16) & 0xFF;
	pktout.body[2] = (rows >> 8) & 0xFF;
	pktout.body[3] = rows & 0xFF;
	pktout.body[4] = (cols >> 24) & 0xFF;
	pktout.body[5] = (cols >> 16) & 0xFF;
	pktout.body[6] = (cols >> 8) & 0xFF;
	pktout.body[7] = cols & 0xFF;
	memset(pktout.body+8, 0, 8);
	s_wrpkt();
            s_wrpkt_start(11, 16);
            pktout.body[0] = (rows >> 24) & 0xFF;
            pktout.body[1] = (rows >> 16) & 0xFF;
            pktout.body[2] = (rows >> 8) & 0xFF;
            pktout.body[3] = rows & 0xFF;
            pktout.body[4] = (cols >> 24) & 0xFF;
            pktout.body[5] = (cols >> 16) & 0xFF;
            pktout.body[6] = (cols >> 8) & 0xFF;
            pktout.body[7] = cols & 0xFF;
            memset(pktout.body+8, 0, 8);
            s_wrpkt();
        }
    }
}

/*
 * (Send Telnet special codes)
 */
static void ssh_special (Telnet_Special code) {