mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
We ought to be using the ssh_pkt_* routines for the messages which we
process at any time in the rdpkt routines, as well as everywhere else. [originally from svn r4669]
This commit is contained in:
parent
ecd50ec349
commit
5ff0e6b1d9
68
ssh.c
68
ssh.c
@ -460,7 +460,7 @@ struct ssh_channel {
|
|||||||
struct ssh_agent_channel {
|
struct ssh_agent_channel {
|
||||||
unsigned char *message;
|
unsigned char *message;
|
||||||
unsigned char msglen[4];
|
unsigned char msglen[4];
|
||||||
int lensofar, totallen;
|
unsigned lensofar, totallen;
|
||||||
} a;
|
} a;
|
||||||
struct ssh_x11_channel {
|
struct ssh_x11_channel {
|
||||||
Socket s;
|
Socket s;
|
||||||
@ -524,6 +524,8 @@ static void ssh_throttle_all(Ssh ssh, int enable, int bufsize);
|
|||||||
static void ssh2_set_window(struct ssh_channel *c, unsigned newwin);
|
static void ssh2_set_window(struct ssh_channel *c, unsigned newwin);
|
||||||
static int ssh_sendbuffer(void *handle);
|
static int ssh_sendbuffer(void *handle);
|
||||||
static void ssh_do_close(Ssh ssh);
|
static void ssh_do_close(Ssh ssh);
|
||||||
|
static unsigned long ssh_pkt_getuint32(Ssh ssh);
|
||||||
|
static void ssh_pkt_getstring(Ssh ssh, char **p, int *length);
|
||||||
|
|
||||||
struct rdpkt1_state_tag {
|
struct rdpkt1_state_tag {
|
||||||
long len, pad, biglen, to_read;
|
long len, pad, biglen, to_read;
|
||||||
@ -972,15 +974,14 @@ static int ssh1_rdpkt(Ssh ssh, unsigned char **data, int *datalen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ssh->pktin.type == SSH1_MSG_DEBUG) {
|
if (ssh->pktin.type == SSH1_MSG_DEBUG) {
|
||||||
/* log debug message */
|
char *buf, *msg;
|
||||||
char buf[512];
|
int msglen;
|
||||||
int stringlen = GET_32BIT(ssh->pktin.body);
|
|
||||||
strcpy(buf, "Remote debug message: ");
|
ssh_pkt_getstring(ssh, &msg, &msglen);
|
||||||
if (stringlen > 480)
|
buf = dupprintf("Remote debug message: %.*s", msglen, msg);
|
||||||
stringlen = 480;
|
|
||||||
memcpy(buf + 8, ssh->pktin.body + 4, stringlen);
|
|
||||||
buf[8 + stringlen] = '\0';
|
|
||||||
logevent(buf);
|
logevent(buf);
|
||||||
|
sfree(buf);
|
||||||
|
|
||||||
goto next_packet;
|
goto next_packet;
|
||||||
} else if (ssh->pktin.type == SSH1_MSG_IGNORE) {
|
} else if (ssh->pktin.type == SSH1_MSG_IGNORE) {
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
@ -989,17 +990,12 @@ static int ssh1_rdpkt(Ssh ssh, unsigned char **data, int *datalen)
|
|||||||
|
|
||||||
if (ssh->pktin.type == SSH1_MSG_DISCONNECT) {
|
if (ssh->pktin.type == SSH1_MSG_DISCONNECT) {
|
||||||
/* log reason code in disconnect message */
|
/* log reason code in disconnect message */
|
||||||
char buf[256];
|
char *msg;
|
||||||
unsigned msglen = GET_32BIT(ssh->pktin.body);
|
int msglen;
|
||||||
unsigned nowlen;
|
|
||||||
strcpy(buf, "Remote sent disconnect: ");
|
ssh_pkt_getstring(ssh, &msg, &msglen);
|
||||||
nowlen = strlen(buf);
|
|
||||||
if (msglen > sizeof(buf) - nowlen - 1)
|
bombout(("Server sent disconnect message:\n\"%.*s\"", msglen, msg));
|
||||||
msglen = sizeof(buf) - nowlen - 1;
|
|
||||||
memcpy(buf + nowlen, ssh->pktin.body + 4, msglen);
|
|
||||||
buf[nowlen + msglen] = '\0';
|
|
||||||
/* logevent(buf); (this is now done within the bombout macro) */
|
|
||||||
bombout(("Server sent disconnect message:\n\"%s\"", buf+nowlen));
|
|
||||||
crStop(0);
|
crStop(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1168,10 +1164,11 @@ static int ssh2_rdpkt(Ssh ssh, unsigned char **data, int *datalen)
|
|||||||
case SSH2_MSG_DISCONNECT:
|
case SSH2_MSG_DISCONNECT:
|
||||||
{
|
{
|
||||||
/* log reason code in disconnect message */
|
/* log reason code in disconnect message */
|
||||||
char *buf;
|
char *buf, *msg;
|
||||||
int nowlen;
|
int nowlen, reason, msglen;
|
||||||
int reason = GET_32BIT(ssh->pktin.data + 6);
|
|
||||||
unsigned msglen = GET_32BIT(ssh->pktin.data + 10);
|
reason = ssh_pkt_getuint32(ssh);
|
||||||
|
ssh_pkt_getstring(ssh, &msg, &msglen);
|
||||||
|
|
||||||
if (reason > 0 && reason < lenof(ssh2_disconnect_reasons)) {
|
if (reason > 0 && reason < lenof(ssh2_disconnect_reasons)) {
|
||||||
buf = dupprintf("Received disconnect message (%s)",
|
buf = dupprintf("Received disconnect message (%s)",
|
||||||
@ -1183,7 +1180,7 @@ static int ssh2_rdpkt(Ssh ssh, unsigned char **data, int *datalen)
|
|||||||
logevent(buf);
|
logevent(buf);
|
||||||
sfree(buf);
|
sfree(buf);
|
||||||
buf = dupprintf("Disconnection message text: %n%.*s",
|
buf = dupprintf("Disconnection message text: %n%.*s",
|
||||||
&nowlen, msglen, ssh->pktin.data + 14);
|
&nowlen, msglen, msg);
|
||||||
logevent(buf);
|
logevent(buf);
|
||||||
bombout(("Server sent disconnect message\ntype %d (%s):\n\"%s\"",
|
bombout(("Server sent disconnect message\ntype %d (%s):\n\"%s\"",
|
||||||
reason,
|
reason,
|
||||||
@ -1199,19 +1196,16 @@ static int ssh2_rdpkt(Ssh ssh, unsigned char **data, int *datalen)
|
|||||||
case SSH2_MSG_DEBUG:
|
case SSH2_MSG_DEBUG:
|
||||||
{
|
{
|
||||||
/* log the debug message */
|
/* log the debug message */
|
||||||
char buf[512];
|
char *buf, *msg;
|
||||||
/* int display = ssh->pktin.body[6]; */
|
int msglen;
|
||||||
int stringlen = GET_32BIT(ssh->pktin.data+7);
|
|
||||||
int prefix;
|
ssh_pkt_getstring(ssh, &msg, &msglen);
|
||||||
strcpy(buf, "Remote debug message: ");
|
|
||||||
prefix = strlen(buf);
|
buf = dupprintf("Remote debug message: %.*s", msglen, msg);
|
||||||
if (stringlen > (int)(sizeof(buf)-prefix-1))
|
|
||||||
stringlen = sizeof(buf)-prefix-1;
|
|
||||||
memcpy(buf + prefix, ssh->pktin.data + 11, stringlen);
|
|
||||||
buf[prefix + stringlen] = '\0';
|
|
||||||
logevent(buf);
|
logevent(buf);
|
||||||
|
sfree(buf);
|
||||||
}
|
}
|
||||||
goto next_packet; /* FIXME: print the debug message */
|
goto next_packet;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These packets we need do nothing about here.
|
* These packets we need do nothing about here.
|
||||||
@ -5254,7 +5248,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
ssh2_pkt_addstring_data(ssh, (char *)pub_blob,
|
ssh2_pkt_addstring_data(ssh, (char *)pub_blob,
|
||||||
pub_blob_len);
|
pub_blob_len);
|
||||||
ssh2_pkt_send(ssh);
|
ssh2_pkt_send(ssh);
|
||||||
logevent("Offered public key"); /* FIXME */
|
logevent("Offered public key");
|
||||||
|
|
||||||
crWaitUntilV(ispkt);
|
crWaitUntilV(ispkt);
|
||||||
if (ssh->pktin.type != SSH2_MSG_USERAUTH_PK_OK) {
|
if (ssh->pktin.type != SSH2_MSG_USERAUTH_PK_OK) {
|
||||||
|
Loading…
Reference in New Issue
Block a user