1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-02 03:52:49 -05:00

Merged SSH1 robustness changes from 0.55 release branch on to trunk.

[originally from svn r4379]
This commit is contained in:
Simon Tatham
2004-08-01 12:07:11 +00:00
parent 29605a0719
commit 4217269931
8 changed files with 528 additions and 200 deletions

10
sshbn.c
View File

@ -540,19 +540,25 @@ Bignum bignum_from_bytes(const unsigned char *data, int nbytes)
/*
* Read an ssh1-format bignum from a data buffer. Return the number
* of bytes consumed.
* of bytes consumed, or -1 if there wasn't enough data.
*/
int ssh1_read_bignum(const unsigned char *data, Bignum * result)
int ssh1_read_bignum(const unsigned char *data, int len, Bignum * result)
{
const unsigned char *p = data;
int i;
int w, b;
if (len < 2)
return -1;
w = 0;
for (i = 0; i < 2; i++)
w = (w << 8) + *p++;
b = (w + 7) / 8; /* bits -> bytes */
if (len < b+2)
return -1;
if (!result) /* just return length */
return b + 2;