|
Ian Kent |
ca38f0 |
autofs-5.0.6 - code analysis fixes 1
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
From: Ian Kent <ikent@redhat.com>
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
Code analysis defect fixes, installment 1.
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
- fix signed usage of unsigned variable in do_srv_query().
|
|
Ian Kent |
ca38f0 |
- make NULL check handling of variable dcs explicit in get_dc_list().
|
|
Ian Kent |
ca38f0 |
- adding an explicit NULL check for variable dcs gaurds against
|
|
Ian Kent |
ca38f0 |
future changes in get_srv_rrs() returning success while not
|
|
Ian Kent |
ca38f0 |
clearing the dcs variable.
|
|
Ian Kent |
ca38f0 |
- makes it explict for readers why we don't need to check for NULL
|
|
Ian Kent |
ca38f0 |
before free later in the loop.
|
|
Ian Kent |
ca38f0 |
- fix typo in do_reconnect()
|
|
Ian Kent |
ca38f0 |
- uri is never set now and, at this point, we need to try to connect
|
|
Ian Kent |
ca38f0 |
to the last server uri (ctxt->uri->uri) which is set in find_server()
|
|
Ian Kent |
ca38f0 |
when ctxt->uri is NULL.
|
|
Ian Kent |
ca38f0 |
---
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
CHANGELOG | 1 +
|
|
Ian Kent |
ca38f0 |
modules/dclist.c | 11 +++++------
|
|
Ian Kent |
ca38f0 |
modules/lookup_ldap.c | 3 +--
|
|
Ian Kent |
ca38f0 |
3 files changed, 7 insertions(+), 8 deletions(-)
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
diff --git a/CHANGELOG b/CHANGELOG
|
|
Ian Kent |
ca38f0 |
index dc91c25..acc5f0c 100644
|
|
Ian Kent |
ca38f0 |
--- a/CHANGELOG
|
|
Ian Kent |
ca38f0 |
+++ b/CHANGELOG
|
|
Ian Kent |
ca38f0 |
@@ -6,6 +6,7 @@
|
|
Ian Kent |
ca38f0 |
- fix dumpmaps not reading maps.
|
|
Ian Kent |
ca38f0 |
- fix result null check in read_one_map().
|
|
Ian Kent |
ca38f0 |
- fix LDAP result leaks on error paths.
|
|
Ian Kent |
ca38f0 |
+- code analysis fixes part 1.
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
28/06/2011 autofs-5.0.6
|
|
Ian Kent |
ca38f0 |
-----------------------
|
|
Ian Kent |
ca38f0 |
diff --git a/modules/dclist.c b/modules/dclist.c
|
|
Ian Kent |
ca38f0 |
index aeb107f..d16b913 100644
|
|
Ian Kent |
ca38f0 |
--- a/modules/dclist.c
|
|
Ian Kent |
ca38f0 |
+++ b/modules/dclist.c
|
|
Ian Kent |
ca38f0 |
@@ -69,7 +69,7 @@ static void dclist_mutex_unlock(void)
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
static int do_srv_query(unsigned int logopt, char *name, u_char **packet)
|
|
Ian Kent |
ca38f0 |
{
|
|
Ian Kent |
ca38f0 |
- unsigned int len = PACKETSZ;
|
|
Ian Kent |
ca38f0 |
+ int len = PACKETSZ;
|
|
Ian Kent |
ca38f0 |
unsigned int last_len = len;
|
|
Ian Kent |
ca38f0 |
char ebuf[MAX_ERR_BUF];
|
|
Ian Kent |
ca38f0 |
u_char *buf;
|
|
Ian Kent |
ca38f0 |
@@ -500,7 +500,8 @@ struct dclist *get_dc_list(unsigned int logopt, const char *uri)
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
dclist_mutex_lock();
|
|
Ian Kent |
ca38f0 |
- if (!get_srv_rrs(logopt, request, &dcs, &numdcs)) {
|
|
Ian Kent |
ca38f0 |
+ ret = get_srv_rrs(logopt, request, &dcs, &numdcs);
|
|
Ian Kent |
ca38f0 |
+ if (!ret | !dcs) {
|
|
Ian Kent |
ca38f0 |
error(logopt,
|
|
Ian Kent |
ca38f0 |
"DNS SRV query failed for domain %s", domain);
|
|
Ian Kent |
ca38f0 |
dclist_mutex_unlock();
|
|
Ian Kent |
ca38f0 |
@@ -526,8 +527,7 @@ struct dclist *get_dc_list(unsigned int logopt, const char *uri)
|
|
Ian Kent |
ca38f0 |
if (!tmp) {
|
|
Ian Kent |
ca38f0 |
char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
Ian Kent |
ca38f0 |
error(logopt, "realloc: %s", estr);
|
|
Ian Kent |
ca38f0 |
- if (dcs)
|
|
Ian Kent |
ca38f0 |
- free_srv_rrs(dcs, numdcs);
|
|
Ian Kent |
ca38f0 |
+ free_srv_rrs(dcs, numdcs);
|
|
Ian Kent |
ca38f0 |
goto out_error;
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
@@ -548,8 +548,7 @@ struct dclist *get_dc_list(unsigned int logopt, const char *uri)
|
|
Ian Kent |
ca38f0 |
if (ret > 6) {
|
|
Ian Kent |
ca38f0 |
error(logopt,
|
|
Ian Kent |
ca38f0 |
"invalid port: %u", dcs[i].port);
|
|
Ian Kent |
ca38f0 |
- if (dcs)
|
|
Ian Kent |
ca38f0 |
- free_srv_rrs(dcs, numdcs);
|
|
Ian Kent |
ca38f0 |
+ free_srv_rrs(dcs, numdcs);
|
|
Ian Kent |
ca38f0 |
goto out_error;
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
strcat(tmp, port);
|
|
Ian Kent |
ca38f0 |
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
|
|
Ian Kent |
ca38f0 |
index 29323b2..67a6834 100644
|
|
Ian Kent |
ca38f0 |
--- a/modules/lookup_ldap.c
|
|
Ian Kent |
ca38f0 |
+++ b/modules/lookup_ldap.c
|
|
Ian Kent |
ca38f0 |
@@ -736,7 +736,6 @@ static LDAP *find_server(unsigned logopt, struct lookup_context *ctxt)
|
|
Ian Kent |
ca38f0 |
static LDAP *do_reconnect(unsigned logopt, struct lookup_context *ctxt)
|
|
Ian Kent |
ca38f0 |
{
|
|
Ian Kent |
ca38f0 |
LDAP *ldap = NULL;
|
|
Ian Kent |
ca38f0 |
- char *uri;
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
if (ctxt->server || !ctxt->uris) {
|
|
Ian Kent |
ca38f0 |
ldap = do_connect(logopt, ctxt->server, ctxt);
|
|
Ian Kent |
ca38f0 |
@@ -780,7 +779,7 @@ static LDAP *do_reconnect(unsigned logopt, struct lookup_context *ctxt)
|
|
Ian Kent |
ca38f0 |
*/
|
|
Ian Kent |
ca38f0 |
if (!ldap) {
|
|
Ian Kent |
ca38f0 |
autofs_sasl_dispose(ctxt);
|
|
Ian Kent |
ca38f0 |
- ldap = connect_to_server(logopt, uri, ctxt);
|
|
Ian Kent |
ca38f0 |
+ ldap = connect_to_server(logopt, ctxt->uri->uri, ctxt);
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
#endif
|
|
Ian Kent |
ca38f0 |
if (ldap)
|