X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/941d39e21d83e4db76f354e6782e24b216027965..717dc4839a39d4235793d152f39fd24e9be9d12b:/ssh.c diff --git a/ssh.c b/ssh.c index 0edaf932..acc4598b 100644 --- a/ssh.c +++ b/ssh.c @@ -885,6 +885,15 @@ static int ssh2_rdpkt(unsigned char **data, int *datalen) st->pad = pktin.data[4]; /* + * _Completely_ silly lengths should be stomped on before they + * do us any more damage. + */ + if (st->len < 0 || st->pad < 0 || st->len + st->pad < 0) { + bombout(("Incoming packet was garbled on decryption")); + crReturn(0); + } + + /* * This enables us to deduce the payload length. */ st->payload = st->len - st->pad - 1;