Re: avoid vfprintf NULL errors in ldape.c log_debug()

2018-07-04 Thread Theo de Raadt
Rob Pierce  wrote:

> Running the current ldapd regression tests result in the following (repeated)
> errors in my /var/log/messages:
> 
> ... ldapd: vfprintf %s NULL in "current bind dn = %s "
> 
> This is because regress/usr.sbin/ldapd/run-tests.pl is performing
> unnecessary unbinds in END { }.
> 
> Though the regression test should probably be fixed, the following diff
> ensures that log_debug is not called with a NULL argument.
> 
> Does this make sense?
> 
> Index: ldape.c
> ===
> RCS file: /cvs/src/usr.sbin/ldapd/ldape.c,v
> retrieving revision 1.27
> diff -u -p -r1.27 ldape.c
> --- ldape.c   15 May 2018 11:19:21 -  1.27
> +++ ldape.c   3 Jul 2018 23:32:27 -
> @@ -229,7 +229,8 @@ ldap_abandon(struct request *req)
>  int
>  ldap_unbind(struct request *req)
>  {
> - log_debug("current bind dn = %s", req->conn->binddn);
> + log_debug("current bind dn = %s",
> + req->conn->binddn == NULL ? "" : req->conn->binddn);
>   conn_disconnect(req->conn);
>   request_free(req);
>   return -1;  /* don't send any response */
> 

I'd suggest:

if (req->conn->binddn)
log_debug("current bind dn = %s", req->conn->binddn);



Re: avoid vfprintf NULL errors in ldape.c log_debug()

2018-07-04 Thread Sebastian Benoit
ok

Rob Pierce(r...@2keys.ca) on 2018.07.03 19:38:51 -0400:
> Running the current ldapd regression tests result in the following (repeated)
> errors in my /var/log/messages:
> 
> ... ldapd: vfprintf %s NULL in "current bind dn = %s "
> 
> This is because regress/usr.sbin/ldapd/run-tests.pl is performing
> unnecessary unbinds in END { }.
> 
> Though the regression test should probably be fixed, the following diff
> ensures that log_debug is not called with a NULL argument.
> 
> Does this make sense?
> 
> Index: ldape.c
> ===
> RCS file: /cvs/src/usr.sbin/ldapd/ldape.c,v
> retrieving revision 1.27
> diff -u -p -r1.27 ldape.c
> --- ldape.c   15 May 2018 11:19:21 -  1.27
> +++ ldape.c   3 Jul 2018 23:32:27 -
> @@ -229,7 +229,8 @@ ldap_abandon(struct request *req)
>  int
>  ldap_unbind(struct request *req)
>  {
> - log_debug("current bind dn = %s", req->conn->binddn);
> + log_debug("current bind dn = %s",
> + req->conn->binddn == NULL ? "" : req->conn->binddn);
>   conn_disconnect(req->conn);
>   request_free(req);
>   return -1;  /* don't send any response */
> 



avoid vfprintf NULL errors in ldape.c log_debug()

2018-07-03 Thread Rob Pierce
Running the current ldapd regression tests result in the following (repeated)
errors in my /var/log/messages:

... ldapd: vfprintf %s NULL in "current bind dn = %s "

This is because regress/usr.sbin/ldapd/run-tests.pl is performing
unnecessary unbinds in END { }.

Though the regression test should probably be fixed, the following diff
ensures that log_debug is not called with a NULL argument.

Does this make sense?

Index: ldape.c
===
RCS file: /cvs/src/usr.sbin/ldapd/ldape.c,v
retrieving revision 1.27
diff -u -p -r1.27 ldape.c
--- ldape.c 15 May 2018 11:19:21 -  1.27
+++ ldape.c 3 Jul 2018 23:32:27 -
@@ -229,7 +229,8 @@ ldap_abandon(struct request *req)
 int
 ldap_unbind(struct request *req)
 {
-   log_debug("current bind dn = %s", req->conn->binddn);
+   log_debug("current bind dn = %s",
+   req->conn->binddn == NULL ? "" : req->conn->binddn);
conn_disconnect(req->conn);
request_free(req);
return -1;  /* don't send any response */