From: John Kohl Date: Fri, 20 Apr 1990 15:02:33 +0000 (+0000) Subject: add a line to the prose description X-Git-Tag: krb5-1.0-alpha2~853 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8f899ae65cb7038b0b1af24a4aff83a8f3dc9f64;p=krb5.git add a line to the prose description 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 --- diff --git a/src/lib/krb5/os/an_to_ln.c b/src/lib/krb5/os/an_to_ln.c index d8fc2b333..be822395a 100644 --- a/src/lib/krb5/os/an_to_ln.c +++ b/src/lib/krb5/os/an_to_ln.c @@ -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