diff options
| author | bcook <> | 2018-08-05 13:35:45 +0000 |
|---|---|---|
| committer | bcook <> | 2018-08-05 13:35:45 +0000 |
| commit | 0d240c50f7f6398b6c3318757e0e84305c126bfe (patch) | |
| tree | 43d58ded7490609a78682579a8ef283f5b3cfef6 /src/lib/libc | |
| parent | e194da0c9fa04c9c6ea539711965b1c64df85f0e (diff) | |
| download | openbsd-0d240c50f7f6398b6c3318757e0e84305c126bfe.tar.gz openbsd-0d240c50f7f6398b6c3318757e0e84305c126bfe.tar.bz2 openbsd-0d240c50f7f6398b6c3318757e0e84305c126bfe.zip | |
Fix a memory leak in i2d_RSA_NET on failure of ASN1_STRING_set.
Found by Coverity.
Feedback and ok tb@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/asn1/n_pkey.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c index d2fabf6e87..6c7031677d 100644 --- a/src/lib/libcrypto/asn1/n_pkey.c +++ b/src/lib/libcrypto/asn1/n_pkey.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: n_pkey.c,v 1.31 2017/01/29 17:49:22 beck Exp $ */ | 1 | /* $OpenBSD: n_pkey.c,v 1.32 2018/08/05 13:35:45 bcook Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -273,11 +273,11 @@ i2d_RSA_NET(const RSA *a, unsigned char **pp, | |||
| 273 | goto err; | 273 | goto err; |
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | enckey->enckey->digest->data = zz; | ||
| 276 | if (!ASN1_STRING_set(enckey->os, "private-key", -1)) { | 277 | if (!ASN1_STRING_set(enckey->os, "private-key", -1)) { |
| 277 | ASN1error(ERR_R_MALLOC_FAILURE); | 278 | ASN1error(ERR_R_MALLOC_FAILURE); |
| 278 | goto err; | 279 | goto err; |
| 279 | } | 280 | } |
| 280 | enckey->enckey->digest->data = zz; | ||
| 281 | i2d_NETSCAPE_PKEY(pkey, &zz); | 281 | i2d_NETSCAPE_PKEY(pkey, &zz); |
| 282 | 282 | ||
| 283 | /* Wipe the private key encoding */ | 283 | /* Wipe the private key encoding */ |
