svn rev #22948: trunk/src/lib/krb5/krb/

lhoward@MIT.EDU lhoward at MIT.EDU
Mon Oct 19 20:48:47 EDT 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=22948
Commit By: lhoward
Log Message:
fix some Coverity reported defects in naming extensions


Changed Files:
U   trunk/src/lib/krb5/krb/authdata.c
U   trunk/src/lib/krb5/krb/copy_auth.c
U   trunk/src/lib/krb5/krb/pac.c
U   trunk/src/lib/krb5/krb/rd_req_dec.c
Modified: trunk/src/lib/krb5/krb/authdata.c
===================================================================
--- trunk/src/lib/krb5/krb/authdata.c	2009-10-19 20:54:43 UTC (rev 22947)
+++ trunk/src/lib/krb5/krb/authdata.c	2009-10-20 00:48:46 UTC (rev 22948)
@@ -408,19 +408,14 @@
 
     context = calloc(1, sizeof(*context));
     if (kcontext == NULL) {
-        if (tables != NULL)
-            krb5int_free_plugin_dir_data(tables);
-        krb5int_close_plugin_dirs(&context->plugins);
-        return ENOMEM;
+        code = ENOMEM;
+        goto cleanup;
     }
     context->magic = KV5M_AUTHDATA_CONTEXT;
     context->modules = calloc(n_modules, sizeof(context->modules[0]));
     if (context->modules == NULL) {
-        if (tables != NULL)
-            krb5int_free_plugin_dir_data(tables);
-        krb5int_close_plugin_dirs(&context->plugins);
-        free(kcontext);
-        return ENOMEM;
+        code = ENOMEM;
+        goto cleanup;
     }
     context->n_modules = n_modules;
 
@@ -428,26 +423,28 @@
     for (i = 0, k = 0, code = 0; i < n_tables - internal_count; i++) {
         code = k5_ad_init_modules(kcontext, context, tables[i], &k);
         if (code != 0)
-            break;
+            goto cleanup;
     }
 
-    if (code == 0) {
-        for (i = 0; i < internal_count; i++) {
-            code = k5_ad_init_modules(kcontext, context, authdata_systems[i], &k);
-            if (code != 0)
-                break;
-        }
+    for (i = 0; i < internal_count; i++) {
+        code = k5_ad_init_modules(kcontext, context, authdata_systems[i], &k);
+        if (code != 0)
+            goto cleanup;
     }
 
+    context->plugins = plugins;
+
+cleanup:
     if (tables != NULL)
         krb5int_free_plugin_dir_data(tables);
 
-    context->plugins = plugins;
-
-    if (code != 0)
+    if (code != 0) {
+        krb5int_close_plugin_dirs(&plugins);
         krb5_authdata_context_free(kcontext, context);
-    else
+    } else {
+        /* plugins is owned by context now */
         *pcontext = context;
+    }
 
     return code;
 }
@@ -596,9 +593,14 @@
     if (authdata != NULL)
         authdata[len] = NULL;
 
+    if (code != 0) {
+        krb5_free_authdata(kcontext, authdata);
+        return code;
+    }
+
     *pauthdata = authdata;
 
-    return code;
+    return 0;
 }
 
 krb5_error_code

Modified: trunk/src/lib/krb5/krb/copy_auth.c
===================================================================
--- trunk/src/lib/krb5/krb/copy_auth.c	2009-10-19 20:54:43 UTC (rev 22947)
+++ trunk/src/lib/krb5/krb/copy_auth.c	2009-10-20 00:48:46 UTC (rev 22948)
@@ -375,6 +375,7 @@
     if (code != 0) {
         krb5_free_ad_kdcissued(context, ad_kdci);
         krb5_free_data(context, data2);
+        return code;
     }
 
     krb5_free_data(context, data2);

Modified: trunk/src/lib/krb5/krb/pac.c
===================================================================
--- trunk/src/lib/krb5/krb/pac.c	2009-10-19 20:54:43 UTC (rev 22947)
+++ trunk/src/lib/krb5/krb/pac.c	2009-10-20 00:48:46 UTC (rev 22948)
@@ -1258,9 +1258,6 @@
     krb5_error_code code;
     krb5_ui_4 type;
 
-    value->data = NULL;
-    value->length = 0;
-
     if (display_value != NULL) {
 	display_value->data = NULL;
 	display_value->length = 0;

Modified: trunk/src/lib/krb5/krb/rd_req_dec.c
===================================================================
--- trunk/src/lib/krb5/krb/rd_req_dec.c	2009-10-19 20:54:43 UTC (rev 22947)
+++ trunk/src/lib/krb5/krb/rd_req_dec.c	2009-10-20 00:48:46 UTC (rev 22948)
@@ -132,7 +132,7 @@
 					   req->ticket);
 
 	    if (retval == 0) {
-		krb5_principal tmp;
+		krb5_principal tmp = NULL;
 
 		/*
 		 * We overwrite ticket->server to be the principal
@@ -152,6 +152,8 @@
 		if (retval == 0) {
 		    krb5_free_principal(context, req->ticket->server);
 		    req->ticket->server = tmp;
+		} else {
+		    krb5_free_principal(context, tmp);
 		}
 		(void) krb5_free_keytab_entry_contents(context, &ktent);
 		break;




More information about the cvs-krb5 mailing list