svn rev #25168: trunk/src/lib/krb5/ccache/

ghudson@MIT.EDU ghudson at MIT.EDU
Wed Sep 7 15:10:25 EDT 2011


http://src.mit.edu/fisheye/changelog/krb5/?cs=25168
Commit By: ghudson
Log Message:
Fix some error-handling bugs in cc_dir.c.


Changed Files:
U   trunk/src/lib/krb5/ccache/cc_dir.c
Modified: trunk/src/lib/krb5/ccache/cc_dir.c
===================================================================
--- trunk/src/lib/krb5/ccache/cc_dir.c	2011-09-06 23:23:43 UTC (rev 25167)
+++ trunk/src/lib/krb5/ccache/cc_dir.c	2011-09-07 19:10:25 UTC (rev 25168)
@@ -184,7 +184,7 @@
     krb5_error_code ret = KRB5_CC_IO;
     char *newpath = NULL;
     FILE *fp = NULL;
-    int fd = -1;
+    int fd = -1, status;
 
     if (asprintf(&newpath, "%s.XXXXXX", primary_path) < 0)
         return ENOMEM;
@@ -200,7 +200,9 @@
     fd = -1;
     if (fprintf(fp, "%s\n", contents) < 0)
         goto cleanup;
-    if (fclose(fp) == EOF)
+    status = fclose(fp);
+    fp = NULL;
+    if (status == EOF)
         goto cleanup;
     fp = NULL;
     if (rename(newpath, primary_path) != 0)
@@ -365,7 +367,7 @@
 {
     krb5_error_code ret;
     char *dirname = NULL, *template = NULL, *residual = NULL;
-    krb5_ccache fcc;
+    krb5_ccache fcc = NULL;
 
     *cache_out = NULL;
     ret = get_context_default_dir(context, &dirname);
@@ -390,9 +392,12 @@
     }
     ret = make_cache(residual, fcc, cache_out);
     if (ret)
-        krb5_fcc_ops.destroy(context, fcc);
+        goto cleanup;
+    fcc = NULL;
 
 cleanup:
+    if (fcc != NULL)
+        krb5_fcc_ops.destroy(context, fcc);
     free(dirname);
     free(template);
     free(residual);




More information about the cvs-krb5 mailing list