diff options
author | Ken Raeburn <raeburn@mit.edu> | 2009-02-05 18:42:10 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@mit.edu> | 2009-02-05 18:42:10 +0000 |
commit | 5726fcb8ee77cebb03087159dfd18f0dfd5733bb (patch) | |
tree | cf8fa9f627198ceb8cf7ade0ca5c0f26f3cd159d /src/lib/kdb | |
parent | 7ddad650cc63bacc2179ffbb22c94b5fe1b55f7c (diff) | |
download | krb5-5726fcb8ee77cebb03087159dfd18f0dfd5733bb.zip krb5-5726fcb8ee77cebb03087159dfd18f0dfd5733bb.tar.gz krb5-5726fcb8ee77cebb03087159dfd18f0dfd5733bb.tar.bz2 |
Create and use (in several places) a variant of
krb5int_copy_data_contents that adds a trailing '\0' so the result can
be used as a C string.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21893 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/kdb')
-rw-r--r-- | src/lib/kdb/kdb_cpw.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/src/lib/kdb/kdb_cpw.c b/src/lib/kdb/kdb_cpw.c index 9f1f2b1..55e8199 100644 --- a/src/lib/kdb/kdb_cpw.c +++ b/src/lib/kdb/kdb_cpw.c @@ -1,7 +1,7 @@ /* * lib/kdb/kdb_cpw.c * - * Copyright 1995 by the Massachusetts Institute of Technology. + * Copyright 1995, 2009 by the Massachusetts Institute of Technology. * All Rights Reserved. * * Export of this software from the United States of America may @@ -431,32 +431,17 @@ add_key_pwd(context, master_key, ks_tuple, ks_tuple_count, passwd, key_salt.data.length = 0; key_salt.data.data = 0; break; - case KRB5_KDB_SALTTYPE_AFS3: { -#if 0 - krb5_data * saltdata; - if (retval = krb5_copy_data(context, krb5_princ_realm(context, - db_entry->princ), &saltdata)) - return(retval); - - key_salt.data = *saltdata; + case KRB5_KDB_SALTTYPE_AFS3: + /* The afs_mit_string_to_key needs to use strlen, and the + realm field is not (necessarily) NULL terminated. */ + retval = krb5int_copy_data_contents_add0(context, + krb5_princ_realm(context, + db_entry->princ), + &key_salt.data); + if (retval) + return retval; key_salt.data.length = SALT_TYPE_AFS_LENGTH; /*length actually used below...*/ - free(saltdata); -#else - /* Why do we do this? Well, the afs_mit_string_to_key needs to - use strlen, and the realm is not NULL terminated.... */ - unsigned int slen = - (*krb5_princ_realm(context,db_entry->princ)).length; - if(!(key_salt.data.data = (char *) malloc(slen+1))) - return ENOMEM; - key_salt.data.data[slen] = 0; - memcpy(key_salt.data.data, - (*krb5_princ_realm(context,db_entry->princ)).data, - slen); - key_salt.data.length = SALT_TYPE_AFS_LENGTH; /*length actually used below...*/ -#endif - - } - break; + break; default: return(KRB5_KDB_BAD_SALTTYPE); } |