зеркало из https://github.com/github/putty.git
Make share_got_pkt_from_server take a const pointer.
It was horrible - even if harmless in practice - that it wrote the NATed channel id over its input buffer, and I think it's worth the extra memory management to avoid doing that.
This commit is contained in:
Родитель
452114c3d3
Коммит
61a972c332
2
ssh.h
2
ssh.h
|
@ -27,7 +27,7 @@ extern Socket ssh_connection_sharing_init(
|
|||
void **state);
|
||||
int ssh_share_test_for_upstream(const char *host, int port, Conf *conf);
|
||||
void share_got_pkt_from_server(void *ctx, int type,
|
||||
unsigned char *pkt, int pktlen);
|
||||
const void *pkt, int pktlen);
|
||||
void share_activate(void *state, const char *server_verstring);
|
||||
void sharestate_free(void *state);
|
||||
int share_ndownstreams(void *state);
|
||||
|
|
10
sshshare.c
10
sshshare.c
|
@ -1129,8 +1129,9 @@ void share_setup_x11_channel(void *csv, void *chanv,
|
|||
}
|
||||
|
||||
void share_got_pkt_from_server(void *csv, int type,
|
||||
unsigned char *pkt, int pktlen)
|
||||
const void *vpkt, int pktlen)
|
||||
{
|
||||
const unsigned char *pkt = (const unsigned char *)vpkt;
|
||||
struct ssh_sharing_connstate *cs = (struct ssh_sharing_connstate *)csv;
|
||||
struct share_globreq *globreq;
|
||||
size_t id_pos;
|
||||
|
@ -1203,8 +1204,11 @@ void share_got_pkt_from_server(void *csv, int type,
|
|||
/*
|
||||
* The normal case: this id refers to an open channel.
|
||||
*/
|
||||
PUT_32BIT(pkt + id_pos, chan->downstream_id);
|
||||
send_packet_to_downstream(cs, type, pkt, pktlen, chan);
|
||||
unsigned char *rewritten = snewn(pktlen, unsigned char);
|
||||
memcpy(rewritten, pkt, pktlen);
|
||||
PUT_32BIT(rewritten + id_pos, chan->downstream_id);
|
||||
send_packet_to_downstream(cs, type, rewritten, pktlen, chan);
|
||||
sfree(rewritten);
|
||||
|
||||
/*
|
||||
* Update the channel state, for messages that need it.
|
||||
|
|
Загрузка…
Ссылка в новой задаче