wincng: Added cast for double to unsigned long conversion

This commit is contained in:
Marc Hoersken 2014-03-22 23:12:59 +01:00
parent 160776d218
commit 2c46c4bf95

View File

@ -1697,7 +1697,8 @@ _libssh2_wincng_bignum_set_word(_libssh2_bn *bn, unsigned long word)
while (number >>= 1) while (number >>= 1)
bits++; bits++;
length = (unsigned long)(ceil((double)(bits+1)/8)*sizeof(unsigned char)); length = (unsigned long) (ceil(((double)(bits + 1)) / 8.0) *
sizeof(unsigned char));
if (_libssh2_wincng_bignum_resize(bn, length)) if (_libssh2_wincng_bignum_resize(bn, length))
return -1; return -1;
@ -1740,23 +1741,26 @@ _libssh2_wincng_bignum_from_bin(_libssh2_bn *bn, unsigned long len,
unsigned char *bignum; unsigned char *bignum;
unsigned long offset, length, bits; unsigned long offset, length, bits;
if (bn && bin && len > 0) { if (!bn || !bin || !len)
if (!_libssh2_wincng_bignum_resize(bn, len)) { return;
memcpy(bn->bignum, bin, len);
bits = _libssh2_wincng_bignum_bits(bn); if (_libssh2_wincng_bignum_resize(bn, len))
length = ceil((double)bits / 8) * sizeof(unsigned char); return;
offset = bn->length - length; memcpy(bn->bignum, bin, len);
if (offset > 0) {
memmove(bn->bignum, bn->bignum + offset, length);
bignum = realloc(bn->bignum, length); bits = _libssh2_wincng_bignum_bits(bn);
if (bignum) { length = (unsigned long) (ceil(((double)bits) / 8.0) *
bn->bignum = bignum; sizeof(unsigned char));
bn->length = length;
} offset = bn->length - length;
} if (offset > 0) {
memmove(bn->bignum, bn->bignum + offset, length);
bignum = realloc(bn->bignum, length);
if (bignum) {
bn->bignum = bignum;
bn->length = length;
} }
} }
} }