“7648a720d9ed8ab413e104f1a65923a31b22a411”上不存在“drivers/mtd/spi-nor/core.c”
提交 b8f1c116 编写于 作者: M Matt Caswell

Don't free the BIGNUM passed to BN_mpi2bn

Commit 91fb42dd fixed a leak but introduced a problem where a parameter
is erroneously freed instead.
Reviewed-by: NTim Hudson <tjh@openssl.org>
Reviewed-by: NRich Salz <rsalz@openssl.org>
上级 098c1e3d
...@@ -87,10 +87,11 @@ int BN_bn2mpi(const BIGNUM *a, unsigned char *d) ...@@ -87,10 +87,11 @@ int BN_bn2mpi(const BIGNUM *a, unsigned char *d)
return (num + 4 + ext); return (num + 4 + ext);
} }
BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a) BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *ain)
{ {
long len; long len;
int neg = 0; int neg = 0;
BIGNUM *a = NULL;
if (n < 4) { if (n < 4) {
BNerr(BN_F_BN_MPI2BN, BN_R_INVALID_LENGTH); BNerr(BN_F_BN_MPI2BN, BN_R_INVALID_LENGTH);
...@@ -103,8 +104,11 @@ BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a) ...@@ -103,8 +104,11 @@ BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a)
return NULL; return NULL;
} }
if (a == NULL) if (ain == NULL)
a = BN_new(); a = BN_new();
else
a = ain;
if (a == NULL) if (a == NULL)
return NULL; return NULL;
...@@ -117,7 +121,8 @@ BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a) ...@@ -117,7 +121,8 @@ BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a)
if ((*d) & 0x80) if ((*d) & 0x80)
neg = 1; neg = 1;
if (BN_bin2bn(d, (int)len, a) == NULL) { if (BN_bin2bn(d, (int)len, a) == NULL) {
BN_free(a); if (ain == NULL)
BN_free(a);
return NULL; return NULL;
} }
a->neg = neg; a->neg = neg;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册