add a line to the prose description
authorJohn Kohl <jtkohl@mit.edu>
Fri, 20 Apr 1990 15:02:33 +0000 (15:02 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Fri, 20 Apr 1990 15:02:33 +0000 (15:02 +0000)
dbm_close() after examining response
add KRB5_LNAME_BADFORMAT if not null-terminated.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@542 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/os/an_to_ln.c

index d8fc2b333cc69ed24afde7acfb1a81bf0fe4fd99..be822395a7e73d56e89a58e50ebe34936f6dcb54 100644 (file)
@@ -42,6 +42,7 @@ static char rcsid_an_to_ln_c[] =
 
  lnsize specifies the maximum length name that is to be filled into
  lname.
+ The translation will be null terminated in all non-error returns.
 
  returns system errors, NOT_ENOUGH_SPACE
 */
@@ -82,17 +83,20 @@ char *lname;
     contents = dbm_fetch(db, key);
 
     xfree(princ_name);
-    (void) dbm_close(db);
 
     if (contents.dptr == NULL) {
        retval = KRB5_LNAME_NOTRANS;
     } else {
        strncpy(lname, contents.dptr, lnsize);
-       if (lnsize < contents.dsize-1)  /* -1 for the null */
+       if (lnsize < contents.dsize)
            retval = KRB5_CONFIG_NOTENUFSPACE;
+       else if (lname[contents.dsize-1] != '\0')
+           retval = KRB5_LNAME_BADFORMAT;
        else
            retval = 0;
     }
+    /* can't close until we copy the contents. */
+    (void) dbm_close(db);
     return retval;
 }
 #else