Re: [Freeipa-devel] [PATCH 0088] Don't error when find_base() fails if a base is not required

2016-01-12 Thread Martin Basti



On 11.01.2016 18:05, Martin Basti wrote:



On 11.01.2016 17:52, Nathaniel McCallum wrote:

On Mon, 2016-01-11 at 17:45 +0100, Martin Basti wrote:


On 14.12.2015 16:22, Nathaniel McCallum wrote:

We always have to call find_base() in order to force libldap to
open
the socket. However, if no base is actually required then there is
no reason to error out if find_base() fails. This condition can
arise
when anonymous binds are disabled.



Hello,

IMO this code may result into free(NULL);

 /* Always find the base since this forces open the socket. */
 basetmp = find_base(ldp);
 if (base != NULL) {
 if (basetmp == NULL)
 return ENOTCONN;
 *base = basetmp;
 } else {
 free(basetmp);  <-- here, if both base and basetmp are NULL
 }

 From the man page for free(): "If ptr is NULL, no operation is
performed."

Nathaniel

Sorry, my bad.

ACK


Pushed to master: 563bddce6d0c3e31f4858edb25f1260af8cc3c44

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [PATCH 0088] Don't error when find_base() fails if a base is not required

2016-01-11 Thread Nathaniel McCallum
On Mon, 2016-01-11 at 17:45 +0100, Martin Basti wrote:
> 
> 
> On 14.12.2015 16:22, Nathaniel McCallum wrote:
> > We always have to call find_base() in order to force libldap to
> > open
> > the socket. However, if no base is actually required then there is
> > no reason to error out if find_base() fails. This condition can
> > arise
> > when anonymous binds are disabled.
> > 
> > 
> Hello,
> 
> IMO this code may result into free(NULL);
> 
>     /* Always find the base since this forces open the socket. */
>     basetmp = find_base(ldp);
>     if (base != NULL) {
>     if (basetmp == NULL)
>     return ENOTCONN;
>     *base = basetmp;
>     } else {
>     free(basetmp);  <-- here, if both base and basetmp are NULL
>     }

>From the man page for free(): "If ptr is NULL, no operation is
performed."

Nathaniel

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Re: [Freeipa-devel] [PATCH 0088] Don't error when find_base() fails if a base is not required

2016-01-11 Thread Martin Basti



On 14.12.2015 16:22, Nathaniel McCallum wrote:

We always have to call find_base() in order to force libldap to open
the socket. However, if no base is actually required then there is
no reason to error out if find_base() fails. This condition can arise
when anonymous binds are disabled.



Hello,

IMO this code may result into free(NULL);

/* Always find the base since this forces open the socket. */
basetmp = find_base(ldp);
if (base != NULL) {
if (basetmp == NULL)
return ENOTCONN;
*base = basetmp;
} else {
free(basetmp);  <-- here, if both base and basetmp are NULL
}


-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

[Freeipa-devel] [PATCH 0088] Don't error when find_base() fails if a base is not required

2015-12-14 Thread Nathaniel McCallum
We always have to call find_base() in order to force libldap to open
the socket. However, if no base is actually required then there is
no reason to error out if find_base() fails. This condition can arise
when anonymous binds are disabled.From 7cb7a7da4271101b7ad089d90716a27dd2041c0d Mon Sep 17 00:00:00 2001
From: Nathaniel McCallum 
Date: Mon, 14 Dec 2015 10:12:26 -0500
Subject: [PATCH] Don't error when find_base() fails if a base is not required

We always have to call find_base() in order to force libldap to open
the socket. However, if no base is actually required then there is
no reason to error out if find_base() fails. This condition can arise
when anonymous binds are disabled.
---
 daemons/ipa-otpd/main.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/daemons/ipa-otpd/main.c b/daemons/ipa-otpd/main.c
index a5d1f93ff06783d9139582aba51587f8f6641c29..aebc039bc05e5ddd04de2c0647a1cdb851a1b697 100644
--- a/daemons/ipa-otpd/main.c
+++ b/daemons/ipa-otpd/main.c
@@ -175,12 +175,13 @@ static krb5_error_code setup_ldap(const char *uri, krb5_boolean bind,
 
 /* Always find the base since this forces open the socket. */
 basetmp = find_base(ldp);
-if (basetmp == NULL)
-return ENOTCONN;
-if (base != NULL)
+if (base != NULL) {
+if (basetmp == NULL)
+return ENOTCONN;
 *base = basetmp;
-else
+} else {
 free(basetmp);
+}
 
 /* Set default timeout to just return immediately for async requests. */
 memset(, 0, sizeof(timeout));
-- 
2.6.4

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code