diff --git a/lib/hcrypto/bn.c b/lib/hcrypto/bn.c index 15bf78738..91933c0a2 100644 --- a/lib/hcrypto/bn.c +++ b/lib/hcrypto/bn.c @@ -142,7 +142,8 @@ BN_bin2bn(const void *s, int len, BIGNUM *bn) return NULL; } hi->length = len; - memcpy(hi->data, s, len); + if (len) + memcpy(hi->data, s, len); return (BIGNUM *)hi; } @@ -250,7 +251,7 @@ BN_set_bit(BIGNUM *bn, int bit) unsigned char *p; if ((bit / 8) > hi->length || hi->length == 0) { - size_t len = (bit + 7) / 8; + size_t len = bit == 0 ? 1 : (bit + 7) / 8; void *d = realloc(hi->data, len); if (d == NULL) return 0; diff --git a/lib/hcrypto/rsa-ltm.c b/lib/hcrypto/rsa-ltm.c index 2852bd4d6..28515195d 100644 --- a/lib/hcrypto/rsa-ltm.c +++ b/lib/hcrypto/rsa-ltm.c @@ -534,8 +534,6 @@ ltm_rsa_generate_key(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb) bitsp = (bits + 1) / 2; - ret = -1; - FIRST(mp_init_multi(&el, &p, &q, &n, &d, &dmp1, &dmq1, &iqmp, &t1, &t2, &t3, NULL));