From d48a413078fd1a0e681e741634a54dc9c92631a9 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Wed, 20 Sep 2000 19:33:21 +0000 Subject: [PATCH] * 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. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12661 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/kdb/ChangeLog | 16 ++++++++++++++++ src/lib/kdb/configure.in | 3 +++ src/lib/kdb/fetch_mkey.c | 11 ++++++++--- src/lib/kdb/kdb_db2.c | 24 +++++++++++++++--------- src/lib/kdb/kdb_xdr.c | 3 ++- src/lib/kdb/store_mkey.c | 5 +++-- 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/lib/kdb/ChangeLog b/src/lib/kdb/ChangeLog index 87f78da09..c5f156beb 100644 --- a/src/lib/kdb/ChangeLog +++ b/src/lib/kdb/ChangeLog @@ -1,3 +1,19 @@ +2000-09-20 Ezra Peisach + + * 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 * encrypt_key.c, kdb_cpw.c, kdb_xdr.c: Add parenthesis about diff --git a/src/lib/kdb/configure.in b/src/lib/kdb/configure.in index e4c33c392..55df06e2e 100644 --- a/src/lib/kdb/configure.in +++ b/src/lib/kdb/configure.in @@ -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 diff --git a/src/lib/kdb/fetch_mkey.c b/src/lib/kdb/fetch_mkey.c index 7ae26bbb9..b8e182af7 100644 --- a/src/lib/kdb/fetch_mkey.c +++ b/src/lib/kdb/fetch_mkey.c @@ -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 diff --git a/src/lib/kdb/kdb_db2.c b/src/lib/kdb/kdb_db2.c index 627aa75ab..c471996bf 100644 --- a/src/lib/kdb/kdb_db2.c +++ b/src/lib/kdb/kdb_db2.c @@ -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); diff --git a/src/lib/kdb/kdb_xdr.c b/src/lib/kdb/kdb_xdr.c index 4a1fb65cc..1d4409743 100644 --- a/src/lib/kdb/kdb_xdr.c +++ b/src/lib/kdb/kdb_xdr.c @@ -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]); } } diff --git a/src/lib/kdb/store_mkey.c b/src/lib/kdb/store_mkey.c index 47e0bc9c0..587850e26 100644 --- a/src/lib/kdb/store_mkey.c +++ b/src/lib/kdb/store_mkey.c @@ -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); } -- 2.26.2