aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/x509/x509_ext.h
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-11-16 12:16:50 -0500
committerJack Lloyd <[email protected]>2017-11-16 12:16:50 -0500
commit966498893af60a1474ea10f1dc3bfbd5b1f43d00 (patch)
tree0c022492e4b59cac1eb6691b79e97cde0d4d9fb5 /src/lib/x509/x509_ext.h
parentf1b54cb3895f1b0007d29bcba90ad693bb7c898d (diff)
Fix a memory leak in the case where certificate extension decoding fails.
Introduced in #884 Found by OSS-Fuzz (bug 4249)
Diffstat (limited to 'src/lib/x509/x509_ext.h')
-rw-r--r--src/lib/x509/x509_ext.h27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/lib/x509/x509_ext.h b/src/lib/x509/x509_ext.h
index 2243d6deb..2cc0115ff 100644
--- a/src/lib/x509/x509_ext.h
+++ b/src/lib/x509/x509_ext.h
@@ -224,27 +224,30 @@ class BOTAN_PUBLIC_API(2,0) Extensions final : public ASN1_Object
#endif
private:
- static Certificate_Extension* create_extn_obj(const OID& oid,
- bool critical,
- const std::vector<uint8_t>& body);
+ static std::unique_ptr<Certificate_Extension>
+ create_extn_obj(const OID& oid,
+ bool critical,
+ const std::vector<uint8_t>& body);
class Extensions_Info
{
public:
Extensions_Info(bool critical,
Certificate_Extension* ext) :
- m_critical(critical),
- m_bits(ext->encode_inner()),
- m_obj(ext)
- {}
+ m_obj(ext),
+ m_bits(m_obj->encode_inner()),
+ m_critical(critical)
+ {
+ }
Extensions_Info(bool critical,
const std::vector<uint8_t>& encoding,
Certificate_Extension* ext) :
- m_critical(critical),
+ m_obj(ext),
m_bits(encoding),
- m_obj(ext)
- {}
+ m_critical(critical)
+ {
+ }
bool is_critical() const { return m_critical; }
const std::vector<uint8_t>& bits() const { return m_bits; }
@@ -255,9 +258,9 @@ class BOTAN_PUBLIC_API(2,0) Extensions final : public ASN1_Object
}
private:
- bool m_critical = false;
+ std::shared_ptr<Certificate_Extension> m_obj;
std::vector<uint8_t> m_bits;
- std::shared_ptr<const Certificate_Extension> m_obj;
+ bool m_critical = false;
};
std::vector<OID> m_extension_oids;