From: Ezra Peisach Date: Tue, 17 Oct 2000 22:59:05 +0000 (+0000) Subject: * fetch_mkey.c: Signed/unsigned int cleanup X-Git-Tag: krb5-1.3-alpha1~1825 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4289b42c30a2c905ee3a3614b55861c22a3bbe74;p=krb5.git * fetch_mkey.c: Signed/unsigned int cleanup * kdb_cpw.c (add_key_pwd): Change salt data length of -1 to SALT_TYPE_AFS_LENGTH. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12778 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/kdb/ChangeLog b/src/lib/kdb/ChangeLog index c5f156beb..4d0d7d5a5 100644 --- a/src/lib/kdb/ChangeLog +++ b/src/lib/kdb/ChangeLog @@ -1,4 +1,11 @@ -2000-09-20 Ezra Peisach +2000-10-17 Ezra Peisach + + * fetch_mkey.c: Signed/unsigned int cleanup. + + * kdb_cpw.c (add_key_pwd): Change salt data length of -1 to + SALT_TYPE_AFS_LENGTH. + +2000-09-20 Ezra Peisach * kdb_xdr.c (krb5_dbe_free_contents): Clean up signedness warning. diff --git a/src/lib/kdb/fetch_mkey.c b/src/lib/kdb/fetch_mkey.c index b8e182af7..5d63b8c0e 100644 --- a/src/lib/kdb/fetch_mkey.c +++ b/src/lib/kdb/fetch_mkey.c @@ -95,7 +95,7 @@ krb5_db_fetch_mkey(context, mname, etype, fromkeyboard, twice, keyfile, krb5_error_code retval; char password[BUFSIZ]; krb5_data pwd; - int size = sizeof(password); + unsigned int size = sizeof(password); if (fromkeyboard) { krb5_data scratch; @@ -126,7 +126,6 @@ krb5_db_fetch_mkey(context, mname, etype, fromkeyboard, twice, keyfile, char defkeyfile[MAXPATHLEN+1]; krb5_data *realm = krb5_princ_realm(context, mname); FILE *kf; - unsigned int len; retval = 0; key->magic = KV5M_KEYBLOCK; @@ -157,22 +156,20 @@ krb5_db_fetch_mkey(context, mname, etype, fromkeyboard, twice, keyfile, retval = KRB5_KDB_CANTREAD_STORED; goto errout; } - if (!key->length || key->length < 0) { + if (!key->length || ((int) key->length) < 0) { retval = KRB5_KDB_BADSTORED_MKEY; goto errout; } - /* Provide an unsigned int */ - len = key->length; - if (!(key->contents = (krb5_octet *)malloc(len))) { + if (!(key->contents = (krb5_octet *)malloc(key->length))) { retval = ENOMEM; goto errout; } if (fread((krb5_pointer) key->contents, - sizeof(key->contents[0]), len, kf) + sizeof(key->contents[0]), key->length, kf) != key->length) { retval = KRB5_KDB_CANTREAD_STORED; - memset(key->contents, 0, len); + memset(key->contents, 0, key->length); free(key->contents); key->contents = 0; } else diff --git a/src/lib/kdb/kdb_cpw.c b/src/lib/kdb/kdb_cpw.c index d39c1cafd..01411e9af 100644 --- a/src/lib/kdb/kdb_cpw.c +++ b/src/lib/kdb/kdb_cpw.c @@ -384,7 +384,7 @@ add_key_pwd(context, master_key, ks_tuple, ks_tuple_count, passwd, return(retval); key_salt.data = *saltdata; - key_salt.data.length = -1; /*length actually used below...*/ + key_salt.data.length = SALT_TYPE_AFS_LENGTH; /*length actually used below...*/ krb5_xfree(saltdata); #else /* Why do we do this? Well, the afs_mit_string_to_key needs to @@ -396,7 +396,7 @@ add_key_pwd(context, master_key, ks_tuple, ks_tuple_count, passwd, memcpy((char *)key_salt.data.data, (char *)(*krb5_princ_realm(context,db_entry->princ)).data, slen); - key_salt.data.length = -1; /*length actually used below...*/ + key_salt.data.length = SALT_TYPE_AFS_LENGTH; /*length actually used below...*/ #endif } @@ -408,6 +408,7 @@ add_key_pwd(context, master_key, ks_tuple, ks_tuple_count, passwd, pwd.data = passwd; pwd.length = strlen(passwd); + /* AFS string to key will happen here */ if ((retval = krb5_c_string_to_key(context, ks_tuple[i].ks_enctype, &pwd, &key_salt.data, &key))) { if (key_salt.data.data) @@ -415,7 +416,7 @@ add_key_pwd(context, master_key, ks_tuple, ks_tuple_count, passwd, return(retval); } - if (key_salt.data.length == -1) + if (key_salt.data.length == SALT_TYPE_AFS_LENGTH) key_salt.data.length = krb5_princ_realm(context, db_entry->princ)->length;