On Sat, Jul 28, 2018 at 05:09:50PM +0200, Theo Buehler wrote:
>[...]
> I'll commit this tomorrow if no-one commits it earlier with my ok.
>
> > [Note that the behaviour of X509_REQ_free(NULL) and X509_NAME_free(NULL)
> > is not documented in the man pages, so those calls in keyproc.c are not
> > modified in this diff.]
>
> They are NULL safe as they're just wrappers around ASN1_item_free().
> (see also the regression test in /usr/src/regress/lib/libcrypto/free/)
>
> So both, a diff that fixes the manuals, and a diff to remove the NULL
> checks in keyproc.c would be great.
>
diffs below:
- fix the manuals [as suggested, plus
for X509_REQ_INFO_free() whilst there]
- remove the NULL checks from keyproc.c [plus add a style(9)
fix whilst there]
Thanks,
Ross
Index: X509_NAME_new.3
===================================================================
RCS file: /cvs/src/lib/libcrypto/man/X509_NAME_new.3,v
retrieving revision 1.5
diff -u -p -r1.5 X509_NAME_new.3
--- X509_NAME_new.3 27 Mar 2018 17:35:50 -0000 1.5
+++ X509_NAME_new.3 29 Jul 2018 05:04:20 -0000
@@ -62,6 +62,11 @@ frees
and all the
.Vt X509_NAME_ENTRY
objects contained in it.
+If
+.Fa name
+is a
+.Dv NULL
+pointer, no action occurs.
.Sh RETURN VALUES
.Fn X509_NAME_new
returns a new
Index: X509_REQ_new.3
===================================================================
RCS file: /cvs/src/lib/libcrypto/man/X509_REQ_new.3,v
retrieving revision 1.4
diff -u -p -r1.4 X509_REQ_new.3
--- X509_REQ_new.3 27 Mar 2018 17:35:50 -0000 1.4
+++ X509_REQ_new.3 29 Jul 2018 05:04:20 -0000
@@ -47,6 +47,11 @@ information about the signature algorith
.Fn X509_REQ_free
frees
.Fa req .
+If
+.Fa req
+is a
+.Dv NULL
+pointer, no action occurs.
.Pp
.Fn X509_REQ_INFO_new
allocates and initializes an empty
@@ -61,6 +66,11 @@ certificate and additional attributes.
.Fn X509_REQ_INFO_free
frees
.Fa req_info .
+If
+.Fa req_info
+is a
+.Dv NULL
+pointer, no action occurs.
.Sh RETURN VALUES
.Fn X509_REQ_new
and
Index: keyproc.c
===================================================================
RCS file: /cvs/src/usr.sbin/acme-client/keyproc.c,v
retrieving revision 1.10
diff -u -p -r1.10 keyproc.c
--- keyproc.c 28 Jul 2018 15:25:23 -0000 1.10
+++ keyproc.c 29 Jul 2018 05:09:40 -0000
@@ -252,12 +252,10 @@ out:
free(der64);
free(sans);
free(san);
- if (x != NULL)
- X509_REQ_free(x);
- if (name != NULL)
- X509_NAME_free(name);
+ X509_REQ_free(x);
+ X509_NAME_free(name);
EVP_PKEY_free(pkey);
ERR_print_errors_fp(stderr);
ERR_free_strings();
- return (rc);
+ return rc;
}