-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Description
@slontis wrote in #12153 (comment):
NOTE that
d2i_X509()callsX509v3_cache_extensions()if the cert object is passed in.
Why has this non-intuitive behavior been added? At least, this must be documented.
If calling X509v3_cache_extensions() is really helpful then better do this also in case no cert object is passed in.
(Update: The issue described in this paragraph is fixed by #13755:
The call of X509v3_cache_extensions() causes trouble: if the caller passed in a pointer to a NULL cert pointer the caller must be very careful in case NULL is returned after the cert was parsed successfully but is invalid such that X509v3_cache_extensions() failed.
In this case the caller needs to free the cert object which has been allocated regardless.)
I have already fixed part of this in #13755 (because I needed it there) such that d2i_X509() behaves consistently at least with d2i_X509_AUX, which deallocates the just created cert object in case an error occurred in its further processing. This way a mem leak is avoided.
@slontis, do you agree with the small improvement I did, and
can you please properly document d2i_X509() and d2i_X509_AUX()?
The description in i2d doc/man3/d2i_X509.pod so far does not cover that new special feature of conditionally calling X509v3_cache_extensions()in d2i_X509() and thus also in d2i_X509_AUX().
Moreover, the deallocation behavior for any passed-in object pointer is not documented for any d2i_TYPE() , neither for d2i_X509_{CERT_,}AUX().