* kdb_xdr.c (krb5_dbe_free_contents): Clean up signedness warning
authorEzra Peisach <epeisach@mit.edu>
Wed, 20 Sep 2000 19:33:21 +0000 (19:33 +0000)
committerEzra Peisach <epeisach@mit.edu>
Wed, 20 Sep 2000 19:33:21 +0000 (19:33 +0000)
* fetch_mkey.c (krb5_db_fetch_mkey): Clean up signedness warnings.

* kdb_db2.c (destroy_file_suffix): Declare function as
static. Rewrite code to use off_t and unsigned ints to handle gcc
warnings. (kdb5_context_internalize) Unmarshal boolean type properly.

* store_mkey.c (krb5_db_store_mkey): Use mode_t instead of int in
call to umask.

* configure.in: Add AC_TYPE_MODE_T and AC_TYPE_OFF_T for mode_t
and off_t declarations.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12661 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/kdb/ChangeLog
src/lib/kdb/configure.in
src/lib/kdb/fetch_mkey.c
src/lib/kdb/kdb_db2.c
src/lib/kdb/kdb_xdr.c
src/lib/kdb/store_mkey.c

index 87f78da09d8f88d4243bdf3f9ca8a319beae99df..c5f156beb8454bc8863ca0e37a0721f4b24f9def 100644 (file)
@@ -1,3 +1,19 @@
+2000-09-20  Ezra Peisach  <epeisach@engrailed.mit.edu>
+
+       * kdb_xdr.c (krb5_dbe_free_contents): Clean up signedness warning.
+
+       * fetch_mkey.c (krb5_db_fetch_mkey): Clean up signedness warnings. 
+
+       * kdb_db2.c (destroy_file_suffix): Declare function as
+       static. Rewrite code to use off_t and unsigned ints to handle gcc
+       warnings. (kdb5_context_internalize) Unmarshal boolean type properly. 
+       
+       * store_mkey.c (krb5_db_store_mkey): Use mode_t instead of int in
+       call to umask.
+
+       * configure.in: Add AC_TYPE_MODE_T and AC_TYPE_OFF_T for mode_t
+       and off_t declarations.
+
 2000-07-04  Ezra Peisach  <epeisach@mit.edu>
 
        * encrypt_key.c, kdb_cpw.c, kdb_xdr.c: Add parenthesis about
index e4c33c3924f68c5596dcc1e3a3b2353e94f5ec0a..55df06e2e57ca6f452f6ceff502413dbc6f19744 100644 (file)
@@ -5,6 +5,9 @@ AC_PROG_ARCHIVE_ADD
 AC_PROG_RANLIB
 AC_PROG_INSTALL
 AC_HAVE_HEADERS(unistd.h)
+AC_TYPE_MODE_T
+AC_TYPE_OFF_T
+
 AC_CHECK_FUNCS(srand48 srand srandom umask)
 
 dnl AIX is unusual in that it wants all symbols resolved at link time
index 7ae26bbb9ccc706d703515f499a42f23fd357996..b8e182af7cdf0b00b82c1818714a51ca1ace7f41 100644 (file)
@@ -126,6 +126,7 @@ 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;
@@ -160,14 +161,18 @@ krb5_db_fetch_mkey(context, mname, etype, fromkeyboard, twice, keyfile,
            retval = KRB5_KDB_BADSTORED_MKEY;
            goto errout;
        }
-       if (!(key->contents = (krb5_octet *)malloc(key->length))) {
+       
+       /* Provide an unsigned int */
+       len = key->length; 
+       if (!(key->contents = (krb5_octet *)malloc(len))) {
            retval = ENOMEM;
            goto errout;
        }
        if (fread((krb5_pointer) key->contents,
-                 sizeof(key->contents[0]), key->length, kf) != key->length) {
+                 sizeof(key->contents[0]), len, kf) 
+           != key->length) {
            retval = KRB5_KDB_CANTREAD_STORED;
-           memset(key->contents, 0, key->length);
+           memset(key->contents, 0, len);
            free(key->contents);
            key->contents = 0;
        } else
index 627aa75abd50dfb788cfe4e6166bf0c5d7ab6510..c471996bfaf6593464d4e0397e344c82dff16bea 100644 (file)
@@ -649,14 +649,16 @@ krb5_db2_db_create(context, db_name, flags)
 /*
  * Destroy the database.  Zero's out all of the files, just to be sure.
  */
-krb5_error_code
+static krb5_error_code
 destroy_file_suffix(dbname, suffix)
     char *dbname;
     char *suffix;
 {
     char *filename;
     struct stat statb;
-    int nb,fd,i,j;
+    int nb,fd;
+    unsigned int j;
+    off_t pos;
     char buf[BUFSIZ];
     char zbuf[BUFSIZ];
     int dowrite;
@@ -685,8 +687,8 @@ destroy_file_suffix(dbname, suffix)
      * we're just about to unlink it anyways.
      */
     memset(zbuf, 0, BUFSIZ);
-    i = 0;
-    while (i < statb.st_size) {
+    pos = 0;
+    while (pos < statb.st_size) {
        dowrite = 0;
        nb = read(fd, buf, BUFSIZ);
        if (nb < 0) {
@@ -700,16 +702,18 @@ destroy_file_suffix(dbname, suffix)
                break;
            }
        }
+       /* For signedness */
+       j = nb;
        if (dowrite) {
-           lseek(fd, i, SEEK_SET);
-           nb = write(fd, zbuf, nb);
+           lseek(fd, pos, SEEK_SET);
+           nb = write(fd, zbuf, j);
            if (nb < 0) {
                int retval = errno;
                free(filename);
                return retval;
            }
        }
-       i += nb;
+       pos += nb;
     }
     /* ??? Is fsync really needed?  I don't know of any non-networked
        filesystem which will discard queued writes to disk if a file
@@ -1087,7 +1091,7 @@ krb5_db2_db_delete_principal(context, searchfor, nentries)
     for (i = 0; i < entry.n_key_data; i++) {
        if (entry.key_data[i].key_data_length[0]) {
            memset((char *)entry.key_data[i].key_data_contents[0], 0, 
-                  entry.key_data[i].key_data_length[0]); 
+                  (unsigned) entry.key_data[i].key_data_length[0]); 
        }
     }
 
@@ -1305,6 +1309,7 @@ kdb5_context_internalize(kcontext, argp, buffer, lenremain)
     krb5_int32         lockcount;
     krb5_int32         lockmode;
     krb5_int32         dbnamelen;
+    krb5_boolean        nb_lock;
     char               *dbname;
 
     bp = *buffer;
@@ -1342,7 +1347,8 @@ kdb5_context_internalize(kcontext, argp, buffer, lenremain)
                        kret = krb5_db_lock(tmpctx, lockmode);
                    if (!kret && lockmode)
                        dbctx->db_locks_held = lockcount;
-                   (void) krb5_db2_db_set_lockmode(tmpctx, nb_lockmode);
+                   nb_lock = nb_lockmode & 0xff;
+                   (void) krb5_db2_db_set_lockmode(tmpctx, nb_lock);
                }
                if (dbname)
                    krb5_xfree(dbname);
index 4a1fb65cc4375dec45e02ef278ae9bd487ba4f6a..1d44097433ad7281e6508d54a039634e2a9a7976 100644 (file)
@@ -688,7 +688,8 @@ krb5_dbe_free_contents(context, entry)
                if (entry->key_data[i].key_data_length[j]) {
                    if (entry->key_data[i].key_data_contents[j]) {
                        memset(entry->key_data[i].key_data_contents[j], 
-                              0, entry->key_data[i].key_data_length[j]);
+                              0, 
+                              (unsigned) entry->key_data[i].key_data_length[j]);
                        free (entry->key_data[i].key_data_contents[j]);
                    }
                }
index 47e0bc9c0d535a6f198c19631941825984fdad26..587850e26d0fbbcd8b2bfff1444ae16cf9ddb8f1 100644 (file)
@@ -60,7 +60,7 @@ krb5_db_store_mkey(context, keyfile, mname, key)
     char defkeyfile[MAXPATHLEN+1];
     krb5_data *realm = krb5_princ_realm(context, mname);
 #if HAVE_UMASK
-    int oumask;
+    mode_t oumask;
 #endif
 
     if (!keyfile) {
@@ -92,7 +92,8 @@ krb5_db_store_mkey(context, keyfile, mname, key)
        (fwrite((krb5_pointer) &key->length,
                sizeof(key->length), 1, kf) != 1) ||
        (fwrite((krb5_pointer) key->contents,
-               sizeof(key->contents[0]), key->length, kf) != key->length)) {
+               sizeof(key->contents[0]), (unsigned) key->length, 
+               kf) != key->length)) {
        retval = errno;
        (void) fclose(kf);
     }