* fetch_mkey.c: Signed/unsigned int cleanup
authorEzra Peisach <epeisach@mit.edu>
Tue, 17 Oct 2000 22:59:05 +0000 (22:59 +0000)
committerEzra Peisach <epeisach@mit.edu>
Tue, 17 Oct 2000 22:59:05 +0000 (22:59 +0000)
        * 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

src/lib/kdb/ChangeLog
src/lib/kdb/fetch_mkey.c
src/lib/kdb/kdb_cpw.c

index c5f156beb8454bc8863ca0e37a0721f4b24f9def..4d0d7d5a529e08ebe5ae92c57a2d878cb1f1f761 100644 (file)
@@ -1,4 +1,11 @@
-2000-09-20  Ezra Peisach  <epeisach@engrailed.mit.edu>
+2000-10-17  Ezra Peisach  <epeisach@mit.edu>
+
+       * 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  <epeisach@mit.edu>
 
        * kdb_xdr.c (krb5_dbe_free_contents): Clean up signedness warning.
 
index b8e182af7cdf0b00b82c1818714a51ca1ace7f41..5d63b8c0ed32350b491e2a6b8a0dce4aea31fd3b 100644 (file)
@@ -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
index d39c1cafde1c1c61fedceb5f174cc2700e18fa9c..01411e9afdb23bacf62ded27b8fe77abc856d566 100644 (file)
@@ -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;