From 74c79ce8cd8759cc27872d56d580681b758ad05c Mon Sep 17 00:00:00 2001 From: jacob Date: Sat, 17 Jun 2006 12:02:03 +0000 Subject: [PATCH] Robert Evans spotted that bignum_decimal() failed to cope with being given a zero input. This shouldn't matter for PuTTY, as these routines are only used in PuTTYgen, to output SSH-1 format public key exponents/moduli, which should be nonzero. git-svn-id: svn://svn.tartarus.org/sgt/putty@6731 cda61777-01e9-0310-a592-d414129be87e --- sshbn.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sshbn.c b/sshbn.c index 728b6fa0..9742c4ad 100644 --- a/sshbn.c +++ b/sshbn.c @@ -1037,9 +1037,14 @@ char *bignum_decimal(Bignum x) * round up (rounding down might make it less than x again). * Therefore if we multiply the bit count by 28/93, rounding * up, we will have enough digits. + * + * i=0 (i.e., x=0) is an irritating special case. */ i = bignum_bitcount(x); - ndigits = (28 * i + 92) / 93; /* multiply by 28/93 and round up */ + if (!i) + ndigits = 1; /* x = 0 */ + else + ndigits = (28 * i + 92) / 93; /* multiply by 28/93 and round up */ ndigits++; /* allow for trailing \0 */ ret = snewn(ndigits, char); -- 2.11.0