Diff

Differences From Artifact [8172e00c0a]:

To Artifact [87acf1a8ee]:


704
705
706
707
708
709
710

711
712
713
714
715
716
717
718
719
720
721
722
723
724
    Pinger pinger;

    /*
     * Track incoming and outgoing data sizes and time, for
     * size-based rekeys.
     */
    unsigned long incoming_data_size, outgoing_data_size, deferred_data_size;

    int kex_in_progress;
    long next_rekey;
};

#define MAX_DATA_BEFORE_REKEY (0x40000000UL)
#define REKEY_TIMEOUT (3600 * TICKSPERSEC)

#define logevent(s) logevent(ssh->frontend, s)

/* logevent, only printf-formatted. */
static void logeventf(Ssh ssh, const char *fmt, ...)
{
    va_list ap;
    char *buf;







>




<
<
<







704
705
706
707
708
709
710
711
712
713
714
715



716
717
718
719
720
721
722
    Pinger pinger;

    /*
     * Track incoming and outgoing data sizes and time, for
     * size-based rekeys.
     */
    unsigned long incoming_data_size, outgoing_data_size, deferred_data_size;
    unsigned long max_data_size;
    int kex_in_progress;
    long next_rekey;
};




#define logevent(s) logevent(ssh->frontend, s)

/* logevent, only printf-formatted. */
static void logeventf(Ssh ssh, const char *fmt, ...)
{
    va_list ap;
    char *buf;
1649
1650
1651
1652
1653
1654
1655

1656
1657
1658
1659
1660
1661
1662
1663
    len = ssh2_pkt_construct(ssh, pkt);
    backlog = sk_write(ssh->s, (char *)pkt->data, len);
    if (backlog > SSH_MAX_BACKLOG)
	ssh_throttle_all(ssh, 1, backlog);

    ssh->outgoing_data_size += pkt->encrypted_len;
    if (!ssh->kex_in_progress &&

	ssh->outgoing_data_size > MAX_DATA_BEFORE_REKEY)
	do_ssh2_transport(ssh, "Initiating key re-exchange "
			  "(too much data sent)", -1, NULL);

    ssh_free_packet(pkt);
}

/*







>
|







1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
    len = ssh2_pkt_construct(ssh, pkt);
    backlog = sk_write(ssh->s, (char *)pkt->data, len);
    if (backlog > SSH_MAX_BACKLOG)
	ssh_throttle_all(ssh, 1, backlog);

    ssh->outgoing_data_size += pkt->encrypted_len;
    if (!ssh->kex_in_progress &&
	ssh->max_data_size != 0 &&
	ssh->outgoing_data_size > ssh->max_data_size)
	do_ssh2_transport(ssh, "Initiating key re-exchange "
			  "(too much data sent)", -1, NULL);

    ssh_free_packet(pkt);
}

/*
1739
1740
1741
1742
1743
1744
1745

1746
1747
1748
1749
1750
1751
1752
1753
    sfree(ssh->deferred_send_data);
    ssh->deferred_send_data = NULL;
    if (backlog > SSH_MAX_BACKLOG)
	ssh_throttle_all(ssh, 1, backlog);

    ssh->outgoing_data_size += ssh->deferred_data_size;
    if (!ssh->kex_in_progress &&

	ssh->outgoing_data_size > MAX_DATA_BEFORE_REKEY)
	do_ssh2_transport(ssh, "Initiating key re-exchange "
			  "(too much data sent)", -1, NULL);
    ssh->deferred_data_size = 0;
}

/*
 * Send all queued SSH2 packets. We send them by means of







>
|







1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
    sfree(ssh->deferred_send_data);
    ssh->deferred_send_data = NULL;
    if (backlog > SSH_MAX_BACKLOG)
	ssh_throttle_all(ssh, 1, backlog);

    ssh->outgoing_data_size += ssh->deferred_data_size;
    if (!ssh->kex_in_progress &&
	ssh->max_data_size != 0 &&
	ssh->outgoing_data_size > ssh->max_data_size)
	do_ssh2_transport(ssh, "Initiating key re-exchange "
			  "(too much data sent)", -1, NULL);
    ssh->deferred_data_size = 0;
}

/*
 * Send all queued SSH2 packets. We send them by means of
4911
4912
4913
4914
4915
4916
4917

4918

4919
4920
4921
4922
4923
4924
4925
4926
	freebn(s->p);
    }

    /*
     * Key exchange is over. Schedule a timer for our next rekey.
     */
    ssh->kex_in_progress = FALSE;

    ssh->next_rekey = schedule_timer(REKEY_TIMEOUT, ssh2_timer, ssh);


    /*
     * If this is the first key exchange phase, we must pass the
     * SSH2_MSG_NEWKEYS packet to the next layer, not because it
     * wants to see it but because it will need time to initialise
     * itself before it sees an actual packet. In subsequent key
     * exchange phases, we don't pass SSH2_MSG_NEWKEYS on, because
     * it would only confuse the layer above.







>
|
>
|







4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
	freebn(s->p);
    }

    /*
     * Key exchange is over. Schedule a timer for our next rekey.
     */
    ssh->kex_in_progress = FALSE;
    if (ssh->cfg.ssh_rekey_time != 0)
	ssh->next_rekey = schedule_timer(ssh->cfg.ssh_rekey_time*60*TICKSPERSEC,
					 ssh2_timer, ssh);
    
    /*
     * If this is the first key exchange phase, we must pass the
     * SSH2_MSG_NEWKEYS packet to the next layer, not because it
     * wants to see it but because it will need time to initialise
     * itself before it sees an actual packet. In subsequent key
     * exchange phases, we don't pass SSH2_MSG_NEWKEYS on, because
     * it would only confuse the layer above.
7083
7084
7085
7086
7087
7088
7089

7090
7091
7092
7093
7094
7095
7096
7097
{
    if (ssh->state == SSH_STATE_CLOSED)
	return;

    if (pktin) {
	ssh->incoming_data_size += pktin->encrypted_len;
	if (!ssh->kex_in_progress &&

	    ssh->incoming_data_size > MAX_DATA_BEFORE_REKEY)
	    do_ssh2_transport(ssh, "Initiating key re-exchange "
			      "(too much data received)", -1, NULL);
    }

    if (pktin && ssh->packet_dispatch[pktin->type]) {
	ssh->packet_dispatch[pktin->type](ssh, pktin);
	return;







>
|







7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
{
    if (ssh->state == SSH_STATE_CLOSED)
	return;

    if (pktin) {
	ssh->incoming_data_size += pktin->encrypted_len;
	if (!ssh->kex_in_progress &&
	    ssh->max_data_size != 0 &&
	    ssh->incoming_data_size > ssh->max_data_size)
	    do_ssh2_transport(ssh, "Initiating key re-exchange "
			      "(too much data received)", -1, NULL);
    }

    if (pktin && ssh->packet_dispatch[pktin->type]) {
	ssh->packet_dispatch[pktin->type](ssh, pktin);
	return;
7205
7206
7207
7208
7209
7210
7211

7212
7213
7214
7215
7216
7217
7218

    ssh->protocol_initial_phase_done = FALSE;

    ssh->pinger = NULL;

    ssh->incoming_data_size = ssh->outgoing_data_size =
	ssh->deferred_data_size = 0L;

    ssh->kex_in_progress = FALSE;

    p = connect_to_host(ssh, host, port, realhost, nodelay, keepalive);
    if (p != NULL)
	return p;

    random_ref();







>







7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222

    ssh->protocol_initial_phase_done = FALSE;

    ssh->pinger = NULL;

    ssh->incoming_data_size = ssh->outgoing_data_size =
	ssh->deferred_data_size = 0L;
    ssh->max_data_size = parse_blocksize(ssh->cfg.ssh_rekey_data);
    ssh->kex_in_progress = FALSE;

    p = connect_to_host(ssh, host, port, realhost, nodelay, keepalive);
    if (p != NULL)
	return p;

    random_ref();