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
*/
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