i2d_ASN1_OBJECT(): allocate memory if the user didn't provide a buffer
authorRichard Levitte <levitte@openssl.org>
Sat, 11 Aug 2018 07:59:20 +0000 (09:59 +0200)
committerRichard Levitte <levitte@openssl.org>
Sat, 11 Aug 2018 10:33:19 +0000 (12:33 +0200)
commit6114041540d8d1fecaf23a861788c3c742d3b467
tree17222b6e8b3401875e1233d1784c123fbacfc14b
parent9553d9691ca67d6cd31573c7f6e567b182800511
i2d_ASN1_OBJECT(): allocate memory if the user didn't provide a buffer

Since 0.9.7, all i2d_ functions were documented to allocate an output
buffer if the user didn't provide one, under these conditions (from
the 1.0.2 documentation):

    For OpenSSL 0.9.7 and later if B<*out> is B<NULL> memory will be
    allocated for a buffer and the encoded data written to it. In this
    case B<*out> is not incremented and it points to the start of the
    data just written.

i2d_ASN1_OBJECT was found not to do this, and would crash if a NULL
output buffer was provided.

Fixes #6914

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/6918)

(cherry picked from commit cba024dc685d13dbcbd0577bed028ee6b295b56a)
crypto/asn1/a_object.c
crypto/asn1/asn1_err.c
include/openssl/asn1.h