lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1473 - nss-pam-ldapd/nslcd

[Date Prev][Date Next] [Thread Prev][Thread Next]

nss-pam-ldapd commit: r1473 - nss-pam-ldapd/nslcd



Author: arthur
Date: Sun Jun  5 22:15:19 2011
New Revision: 1473
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1473

Log:
mark more strings as const and don't free() data returned by cfg_getdomainname()

Modified:
   nss-pam-ldapd/nslcd/cfg.c
   nss-pam-ldapd/nslcd/common.c

Modified: nss-pam-ldapd/nslcd/cfg.c
==============================================================================
--- nss-pam-ldapd/nslcd/cfg.c   Sun Jun  5 11:18:08 2011        (r1472)
+++ nss-pam-ldapd/nslcd/cfg.c   Sun Jun  5 22:15:19 2011        (r1473)
@@ -170,9 +170,9 @@
 #ifdef HAVE_LDAP_DOMAIN2HOSTLIST
 /* return the domain name of the current host
    the returned string must be freed by caller */
-static char *cfg_getdomainname(const char *filename,int lnr)
+static const char *cfg_getdomainname(const char *filename,int lnr)
 {
-  char *fqdn,*domain;
+  const char *fqdn,*domain;
   fqdn=getfqdn();
   if ((fqdn!=NULL)&&((domain=strchr(fqdn,'.'))!=NULL)&&(domain[1]!='\0'))
     return domain+1;
@@ -185,12 +185,12 @@
 static void add_uris_from_dns(const char *filename,int lnr,
                               struct ldap_config *cfg)
 {
-  int ret=0;
-  char *domain;
+  int rc;
+  const char *domain;
   char *hostlist=NULL,*nxt;
   char buf[HOST_NAME_MAX+sizeof("ldap://")];
   domain=cfg_getdomainname(filename,lnr);
-  ret=ldap_domain2hostlist(domain,&hostlist);
+  rc=ldap_domain2hostlist(domain,&hostlist);
   /* FIXME: have better error handling */
   if ((hostlist==NULL)||(*hostlist=='\0'))
   {
@@ -554,7 +554,7 @@
                      const char *value,const char **var)
 {
 #ifdef HAVE_LDAP_DOMAIN2DN
-  char *domain = NULL;
+  const char *domain=NULL;
   char *domaindn=NULL;
 #endif /* HAVE_LDAP_DOMAIN2DN */
   /* if the base is "DOMAIN" use the domain name */
@@ -563,7 +563,6 @@
 #ifdef HAVE_LDAP_DOMAIN2DN
     domain=cfg_getdomainname(filename,lnr);
     ldap_domain2dn(domain,&domaindn);
-    free(domain);
     log_log(LOG_DEBUG,"set_base(): setting base to %s from domain",domaindn);
     value=domaindn;
 #else /* not HAVE_LDAP_DOMAIN2DN */

Modified: nss-pam-ldapd/nslcd/common.c
==============================================================================
--- nss-pam-ldapd/nslcd/common.c        Sun Jun  5 11:18:08 2011        (r1472)
+++ nss-pam-ldapd/nslcd/common.c        Sun Jun  5 22:15:19 2011        (r1473)
@@ -99,7 +99,7 @@
         (host->h_aliases[i][hostnamelen]=='.')&&
         (host->h_aliases[i][hostnamelen+1]!='\0'))
     {
-      fqdn=host->h_aliases[i];
+      fqdn=strdup(host->h_aliases[i]);
       return fqdn;
     }
   }
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits