svn rev #21838: trunk/src/ include/ kdc/ lib/kadm5/ lib/kadm5/srv/

tsitkova@MIT.EDU tsitkova at MIT.EDU
Fri Jan 30 15:40:48 EST 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=21838
Commit By: tsitkova
Log Message:
Changed the name match_config_pattern to krb5_match_config_pattern. Check strdup return code. 



Changed Files:
U   trunk/src/include/adm_proto.h
U   trunk/src/kdc/do_tgs_req.c
U   trunk/src/kdc/main.c
U   trunk/src/lib/kadm5/alt_prof.c
U   trunk/src/lib/kadm5/srv/libkadm5srv.exports
Modified: trunk/src/include/adm_proto.h
===================================================================
--- trunk/src/include/adm_proto.h	2009-01-30 20:27:48 UTC (rev 21837)
+++ trunk/src/include/adm_proto.h	2009-01-30 20:40:46 UTC (rev 21838)
@@ -97,7 +97,7 @@
 					krb5_realm_params **);
 krb5_error_code krb5_free_realm_params (krb5_context,
 					krb5_realm_params *);
-krb5_boolean match_config_pattern(const char *, const char *);
+krb5_boolean krb5_match_config_pattern(const char *, const char *);
 
 /* str_conv.c */
 krb5_error_code

Modified: trunk/src/kdc/do_tgs_req.c
===================================================================
--- trunk/src/kdc/do_tgs_req.c	2009-01-30 20:27:48 UTC (rev 21837)
+++ trunk/src/kdc/do_tgs_req.c	2009-01-30 20:40:46 UTC (rev 21838)
@@ -1082,11 +1082,11 @@
         if ((krb5_princ_type(kdc_context, request->server) == KRB5_NT_SRV_HST || 
             (krb5_princ_type(kdc_context, request->server) == KRB5_NT_UNKNOWN &&   
             kdc_active_realm->realm_host_based_services != NULL &&
-            (match_config_pattern(kdc_active_realm->realm_host_based_services, comp1_str) == TRUE ||
-             match_config_pattern(kdc_active_realm->realm_host_based_services, "*") == TRUE))) &&
+            (krb5_match_config_pattern(kdc_active_realm->realm_host_based_services, comp1_str) == TRUE ||
+             krb5_match_config_pattern(kdc_active_realm->realm_host_based_services, "*") == TRUE))) &&
             (kdc_active_realm->realm_no_host_referral == NULL || 
-            (match_config_pattern(kdc_active_realm->realm_no_host_referral, "*") == FALSE &&
-             match_config_pattern(kdc_active_realm->realm_no_host_referral, comp1_str) == FALSE))) { 
+            (krb5_match_config_pattern(kdc_active_realm->realm_no_host_referral, "*") == FALSE &&
+             krb5_match_config_pattern(kdc_active_realm->realm_no_host_referral, comp1_str) == FALSE))) { 
 
             for (len=0; len < comp2->length; len++) {     
                  if (comp2->data[len] == '.') break;

Modified: trunk/src/kdc/main.c
===================================================================
--- trunk/src/kdc/main.c	2009-01-30 20:27:48 UTC (rev 21837)
+++ trunk/src/kdc/main.c	2009-01-30 20:40:46 UTC (rev 21838)
@@ -173,13 +173,17 @@
 {
     krb5_error_code retval = 0;
 
-    if (no_refrls && match_config_pattern(no_refrls, "*") == TRUE)
+    if (no_refrls && krb5_match_config_pattern(no_refrls, "*") == TRUE) {
         rdp->realm_no_host_referral = strdup("*");
-    else {
+        if (!rdp->realm_no_host_referral)
+            retval = ENOMEM;
+    } else {
         if (rparams && rparams->realm_no_host_referral) {
-            if (match_config_pattern(rparams->realm_no_host_referral, "*") == TRUE)
+            if (krb5_match_config_pattern(rparams->realm_no_host_referral, "*") == TRUE) {
                 rdp->realm_no_host_referral = strdup("*");
-            else if  (no_refrls && (asprintf(&(rdp->realm_no_host_referral), "%s%s%s%s%s",
+                if (!rdp->realm_no_host_referral)
+                    retval = ENOMEM;
+           } else if  (no_refrls && (asprintf(&(rdp->realm_no_host_referral), "%s%s%s%s%s",
                         " ", no_refrls," ",rparams->realm_no_host_referral, " ") < 0))
                 retval = ENOMEM; 
             else if (asprintf(&(rdp->realm_no_host_referral),"%s%s%s", " ", 
@@ -191,18 +195,22 @@
             rdp->realm_no_host_referral = NULL;
     }
 
-    if (rdp->realm_no_host_referral && match_config_pattern(rdp->realm_no_host_referral, "*") == TRUE) {
+    if (rdp->realm_no_host_referral && krb5_match_config_pattern(rdp->realm_no_host_referral, "*") == TRUE) {
         rdp->realm_host_based_services = NULL; 
         return 0;
     }
 
-    if (host_based_srvcs && (match_config_pattern(host_based_srvcs, "*") == TRUE))
+    if (host_based_srvcs && (krb5_match_config_pattern(host_based_srvcs, "*") == TRUE)) {
             rdp->realm_host_based_services = strdup("*");
-    else {
+            if (!rdp->realm_host_based_services)
+                retval = ENOMEM;
+    } else {
             if (rparams && rparams->realm_host_based_services) {
-                if (match_config_pattern(rparams->realm_host_based_services, "*") == TRUE)
+                if (krb5_match_config_pattern(rparams->realm_host_based_services, "*") == TRUE) {
                     rdp->realm_host_based_services = strdup("*");
-                else if (host_based_srvcs && asprintf(&(rdp->realm_host_based_services), "%s%s%s%s%s",
+                    if (!rdp->realm_host_based_services)
+                        retval = ENOMEM;
+                } else if (host_based_srvcs && asprintf(&(rdp->realm_host_based_services), "%s%s%s%s%s",
                            " ", host_based_srvcs," ",rparams->realm_host_based_services, " ") < 0)
                     retval = ENOMEM; 
                 else if (asprintf(&(rdp->realm_host_based_services),"%s%s%s", " ", 
@@ -257,8 +265,13 @@
     }
     
     /* Handle profile file name */
-    if (rparams && rparams->realm_profile)
+    if (rparams && rparams->realm_profile) {
 	rdp->realm_profile = strdup(rparams->realm_profile);
+        if (!rdp->realm_profile) {
+            kret = ENOMEM;
+            goto whoops;
+        }
+    }
 
     /* Handle master key name */
     if (rparams && rparams->realm_mkey_name)
@@ -266,20 +279,35 @@
     else
 	rdp->realm_mpname = (def_mpname) ? strdup(def_mpname) :
 	    strdup(KRB5_KDB_M_NAME);
+    if (!rdp->realm_mpname) {
+        kret = ENOMEM;
+        goto whoops;
+    }
 
     /* Handle KDC ports */
     if (rparams && rparams->realm_kdc_ports)
 	rdp->realm_ports = strdup(rparams->realm_kdc_ports);
     else
 	rdp->realm_ports = strdup(def_udp_ports);
+    if (!rdp->realm_ports) {
+        kret = ENOMEM;
+        goto whoops;
+    }
     if (rparams && rparams->realm_kdc_tcp_ports)
 	rdp->realm_tcp_ports = strdup(rparams->realm_kdc_tcp_ports);
     else
 	rdp->realm_tcp_ports = strdup(def_tcp_ports);
-
+    if (!rdp->realm_tcp_ports) {
+        kret = ENOMEM;
+        goto whoops;
+    }
     /* Handle stash file */
     if (rparams && rparams->realm_stash_file) {
 	rdp->realm_stash = strdup(rparams->realm_stash_file);
+        if (!rdp->realm_stash) {
+            kret = ENOMEM;
+            goto whoops;
+        }
 	manual = FALSE;
     } else
 	manual = def_manual;
@@ -519,7 +547,7 @@
         hierarchy[1] = "no_host_referral";
         if (krb5_aprof_get_string_all(aprof, hierarchy, &no_refrls)) 
             no_refrls = 0;
-        if (!no_refrls || match_config_pattern(no_refrls, "*") == FALSE) {
+        if (!no_refrls || krb5_match_config_pattern(no_refrls, "*") == FALSE) {
             hierarchy[1] = "host_based_services";
             if (krb5_aprof_get_string_all(aprof, hierarchy, &host_based_srvcs))
                 host_based_srvcs = 0;
@@ -530,10 +558,22 @@
 	     krb5_aprof_finish(aprof);
     }
   
-    if (default_udp_ports == 0)
+    if (default_udp_ports == 0) {
 	default_udp_ports = strdup(DEFAULT_KDC_UDP_PORTLIST);
-    if (default_tcp_ports == 0)
+        if (default_udp_ports == 0) {
+            fprintf(stderr," KDC cannot initialize. Not enough memory\n");
+            exit(1);
+        }
+    }
+    if (default_tcp_ports == 0) {
 	default_tcp_ports = strdup(DEFAULT_KDC_TCP_PORTLIST);
+        default_tcp_ports = strdup(DEFAULT_KDC_TCP_PORTLIST);
+        if (default_tcp_ports == 0) {
+            fprintf(stderr," KDC cannot initialize. Not enough memory\n");
+            exit(1);
+        }
+    }
+
     /*
      * Loop through the option list.  Each time we encounter a realm name,
      * use the previously scanned options to fill in for defaults.
@@ -629,6 +669,10 @@
 	    if (default_udp_ports)
 		free(default_udp_ports);
 	    default_udp_ports = strdup(optarg);
+            if (!default_udp_ports) {
+                fprintf(stderr," KDC cannot initialize. Not enough memory\n");
+                exit(1);
+            }
 #if 0 /* not yet */
 	    if (default_tcp_ports)
 		free(default_tcp_ports);
@@ -693,6 +737,10 @@
 	free(db_args);
     if (db_name)
 	free(db_name);
+    if (host_based_srvcs)
+        free(host_based_srvcs);
+    if (no_refrls)
+        free(no_refrls);
 
     return;
 }

Modified: trunk/src/lib/kadm5/alt_prof.c
===================================================================
--- trunk/src/lib/kadm5/alt_prof.c	2009-01-30 20:27:48 UTC (rev 21837)
+++ trunk/src/lib/kadm5/alt_prof.c	2009-01-30 20:40:46 UTC (rev 21838)
@@ -39,7 +39,7 @@
 #include <ctype.h>
 #include <kdb_log.h>
 
-krb5_boolean match_config_pattern(const char *, const char*);
+krb5_boolean krb5_match_config_pattern(const char *, const char*);
 static krb5_key_salt_tuple *copy_key_salt_tuple(ksalt, len)
 krb5_key_salt_tuple *ksalt;
 krb5_int32 len;
@@ -1035,7 +1035,7 @@
     else 
             no_refrls = 0;
 
-    if (!no_refrls || match_config_pattern(no_refrls, "*") == FALSE) {
+    if (!no_refrls || krb5_match_config_pattern(no_refrls, "*") == FALSE) {
         hierarchy[2] = "host_based_services";
         if (!krb5_aprof_get_string_all(aprofile, hierarchy, &host_based_srvcs))
             rparams->realm_host_based_services = host_based_srvcs;
@@ -1124,7 +1124,7 @@
  *       In conf file the values are separates by commas or whitespaces.
  */
 krb5_boolean
-match_config_pattern(const char *string, const char *pattern)
+krb5_match_config_pattern(const char *string, const char *pattern)
 {
     const char *ptr;
     char next = '\0';

Modified: trunk/src/lib/kadm5/srv/libkadm5srv.exports
===================================================================
--- trunk/src/lib/kadm5/srv/libkadm5srv.exports	2009-01-30 20:27:48 UTC (rev 21837)
+++ trunk/src/lib/kadm5/srv/libkadm5srv.exports	2009-01-30 20:40:46 UTC (rev 21838)
@@ -84,7 +84,7 @@
 krb5_read_realm_params
 krb5_string_to_flags
 krb5_string_to_keysalts
-match_config_pattern
+krb5_match_config_pattern
 master_db
 master_keyblock
 master_princ




More information about the cvs-krb5 mailing list