1
- .\" $OpenBSD: d2i_ASN1_OBJECT.3,v 1.11 2021/12/08 13:21:04 schwarze Exp $
2
- .\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400
1
+ .\" $OpenBSD: d2i_ASN1_OBJECT.3,v 1.12 2022/03/29 17:41:20 schwarze Exp $
3
2
.\"
4
- .\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
3
+ .\" Copyright (c) 2017, 2022 Ingo Schwarze <schwarze@openbsd.org>
5
4
.\"
6
5
.\" Permission to use, copy, modify, and distribute this software for any
7
6
.\" purpose with or without fee is hereby granted, provided that the above
15
14
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
15
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
16
.\"
18
- .Dd $Mdocdate : December 8 2021 $
17
+ .Dd $Mdocdate : March 29 2022 $
19
18
.Dt D2I_ASN1_OBJECT 3
20
19
.Os
21
20
.Sh NAME
@@ -42,32 +41,36 @@ These functions decode and encode ASN.1 object identifiers.
42
41
For details about the semantics, examples, caveats, and bugs, see
43
42
.Xr ASN1_item_d2i 3 .
44
43
.Pp
44
+ The LibreSSL implementation of
45
+ .Fn d2i_ASN1_OBJECT
46
+ always calls
47
+ .Xr ASN1_OBJECT_free 3
48
+ if an existing object is passed in via
49
+ .Fa val_out
50
+ and it always creates a new object from scratch.
51
+ Other implementations may attempt to reuse an existing object,
52
+ which is fragile and prone to bugs.
53
+ Consequently, always passing
54
+ .Dv NULL
55
+ for the
56
+ .Fa val_out
57
+ argument is recommended.
58
+ .Pp
45
59
The objects returned from
46
60
.Fn d2i_ASN1_OBJECT
47
61
and the data contained in them are always marked as dynamically
48
62
allocated, so when they are no longer needed,
49
63
.Xr ASN1_OBJECT_free 3
50
64
can be called on them.
51
- .Pp
52
- If reusing an existing object is attempted but the
53
- .Pf * Fa val_out
54
- passed in points to an object that is not marked as dynamically
55
- allocated, then the existing object is left untouched and
56
- .Fn d2i_ASN1_OBJECT
57
- behaves as if
58
- .Pf * Fa val_out
59
- would have been
60
- .Dv NULL :
61
- A new object is allocated and a pointer to it is both stored in
62
- .Pf * Fa val_out
63
- and returned.
64
65
.Sh RETURN VALUES
65
66
.Fn d2i_ASN1_OBJECT
66
- returns an
67
+ returns a pointer to the new
67
68
.Vt ASN1_OBJECT
68
69
object or
69
70
.Dv NULL
70
71
if an error occurs.
72
+ With other implementations, it might return a pointer to the reused
73
+ .Vt ASN1_OBJECT .
71
74
.Pp
72
75
.Fn i2d_ASN1_OBJECT
73
76
returns the number of bytes successfully encoded
@@ -101,7 +104,3 @@ on the returned object, and then
101
104
and
102
105
.Xr OBJ_nid2ln 3
103
106
on the result.
104
- .Sh BUGS
105
- When reusing a dynamically allocated object that contains dynamically
106
- allocated names, the old names are not freed and the memory containing
107
- them is leaked.
0 commit comments