Skip to content

Commit 42ba3d7

Browse files
author
schwarze
committed
Given asn1/a_object.c rev. 1.45 by jsing@, stop talking about BUGS
we no longer have, focus on what our implementation now does, but keep short warnings in how far other implementations might be more fragile. Some improvements to wordings and clarity while here. OK tb@
1 parent 46d2a4d commit 42ba3d7

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/lib/libcrypto/man/d2i_ASN1_OBJECT.3

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
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 $
32
.\"
4-
.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
3+
.\" Copyright (c) 2017, 2022 Ingo Schwarze <schwarze@openbsd.org>
54
.\"
65
.\" Permission to use, copy, modify, and distribute this software for any
76
.\" purpose with or without fee is hereby granted, provided that the above
@@ -15,7 +14,7 @@
1514
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1615
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1716
.\"
18-
.Dd $Mdocdate: December 8 2021 $
17+
.Dd $Mdocdate: March 29 2022 $
1918
.Dt D2I_ASN1_OBJECT 3
2019
.Os
2120
.Sh NAME
@@ -42,32 +41,36 @@ These functions decode and encode ASN.1 object identifiers.
4241
For details about the semantics, examples, caveats, and bugs, see
4342
.Xr ASN1_item_d2i 3 .
4443
.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
4559
The objects returned from
4660
.Fn d2i_ASN1_OBJECT
4761
and the data contained in them are always marked as dynamically
4862
allocated, so when they are no longer needed,
4963
.Xr ASN1_OBJECT_free 3
5064
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.
6465
.Sh RETURN VALUES
6566
.Fn d2i_ASN1_OBJECT
66-
returns an
67+
returns a pointer to the new
6768
.Vt ASN1_OBJECT
6869
object or
6970
.Dv NULL
7071
if an error occurs.
72+
With other implementations, it might return a pointer to the reused
73+
.Vt ASN1_OBJECT .
7174
.Pp
7275
.Fn i2d_ASN1_OBJECT
7376
returns the number of bytes successfully encoded
@@ -101,7 +104,3 @@ on the returned object, and then
101104
and
102105
.Xr OBJ_nid2ln 3
103106
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

Comments
 (0)