pull up r19038 from trunk
authorTom Yu <tlyu@mit.edu>
Thu, 29 Mar 2007 21:36:12 +0000 (21:36 +0000)
committerTom Yu <tlyu@mit.edu>
Thu, 29 Mar 2007 21:36:12 +0000 (21:36 +0000)
 r19038@cathode-dark-space:  raeburn | 2007-01-08 17:41:01 -0500
 ticket: new
 subject: crash creating db2 database in non-existent directory

 * kdb_db2.c (krb5_db2_db_create): If the creation of the first database file
 fails, return the error, instead of attempting to create the second (and using
 a null pointer as an input string in formatting a filename).

 Reported by Jeff Blaine.

ticket: 5293
version_fixed: 1.6.1

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@19308 dc483132-0cff-0310-8789-dd5450dbe970

src/plugins/kdb/db2/kdb_db2.c

index 9a0254dd3d57984a5638dd1668f8f8fe9ddc6506..d438171cbdb0fe670f5eb3285f1256986862f9ba 100644 (file)
@@ -702,25 +702,22 @@ krb5_db2_db_create(krb5_context context, char *db_name, krb5_int32 flags)
     }
     db = k5db2_dbopen(db_ctx, db_name, O_RDWR | O_CREAT | O_EXCL, 0600, db_ctx->tempdb);
     if (db == NULL)
-       retval = errno;
-    else
-       (*db->close) (db);
-    if (retval == 0) {
+       return errno;
+    (*db->close) (db);
 
-       db_name2 = db_ctx->tempdb ? gen_dbsuffix(db_name, "~") : strdup(db_name);
-       if (db_name2 == NULL)
-           return ENOMEM;
-       okname = gen_dbsuffix(db_name2, KDB2_LOCK_EXT);
-       if (!okname)
-           retval = ENOMEM;
-       else {
-           fd = open(okname, O_CREAT | O_RDWR | O_TRUNC, 0600);
-           if (fd < 0)
-               retval = errno;
-           else
-               close(fd);
-           free_dbsuffix(okname);
-       }
+    db_name2 = db_ctx->tempdb ? gen_dbsuffix(db_name, "~") : strdup(db_name);
+    if (db_name2 == NULL)
+       return ENOMEM;
+    okname = gen_dbsuffix(db_name2, KDB2_LOCK_EXT);
+    if (!okname)
+       retval = ENOMEM;
+    else {
+       fd = open(okname, O_CREAT | O_RDWR | O_TRUNC, 0600);
+       if (fd < 0)
+           retval = errno;
+       else
+           close(fd);
+       free_dbsuffix(okname);
     }
 
     sprintf(policy_db_name, "%s.kadm5", db_name2);