From 4f7713802fc75f1fe85255e94d4932b3bbb2de4f Mon Sep 17 00:00:00 2001 From: Keith Vetter Date: Wed, 8 Mar 1995 01:04:08 +0000 Subject: [PATCH] Ported the ccache directory to the PC. This is temporary--eventually we'll use the in-memory solution from k4. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5081 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/ChangeLog | 5 ++ src/lib/krb5/ccache/Makefile.in | 31 ++++++++-- src/lib/krb5/ccache/ccbase.c | 5 +- src/lib/krb5/ccache/ccdefault.c | 3 +- src/lib/krb5/ccache/file/ChangeLog | 8 +++ src/lib/krb5/ccache/file/Makefile.in | 17 ++++-- src/lib/krb5/ccache/file/fcc-proto.h | 82 +++++++++++++-------------- src/lib/krb5/ccache/file/fcc.h | 1 + src/lib/krb5/ccache/file/fcc_close.c | 4 +- src/lib/krb5/ccache/file/fcc_defnam.c | 2 +- src/lib/krb5/ccache/file/fcc_destry.c | 29 ++++++---- src/lib/krb5/ccache/file/fcc_errs.c | 4 +- src/lib/krb5/ccache/file/fcc_eseq.c | 2 +- src/lib/krb5/ccache/file/fcc_gennew.c | 8 ++- src/lib/krb5/ccache/file/fcc_getnam.c | 2 +- src/lib/krb5/ccache/file/fcc_gprin.c | 2 +- src/lib/krb5/ccache/file/fcc_init.c | 21 +++---- src/lib/krb5/ccache/file/fcc_maybe.c | 11 ++-- src/lib/krb5/ccache/file/fcc_nseq.c | 13 ++--- src/lib/krb5/ccache/file/fcc_read.c | 66 +++++++++++++-------- src/lib/krb5/ccache/file/fcc_reslv.c | 2 +- src/lib/krb5/ccache/file/fcc_retrv.c | 2 +- src/lib/krb5/ccache/file/fcc_sflags.c | 2 +- src/lib/krb5/ccache/file/fcc_skip.c | 2 +- src/lib/krb5/ccache/file/fcc_sseq.c | 14 ++--- src/lib/krb5/ccache/file/fcc_store.c | 2 +- src/lib/krb5/ccache/file/fcc_write.c | 40 ++++++------- 27 files changed, 226 insertions(+), 154 deletions(-) diff --git a/src/lib/krb5/ccache/ChangeLog b/src/lib/krb5/ccache/ChangeLog index 69642720d..edc3497c4 100644 --- a/src/lib/krb5/ccache/ChangeLog +++ b/src/lib/krb5/ccache/ChangeLog @@ -1,3 +1,8 @@ +Tue Mar 7 15:55:12 1995 Keith Vetter (keithv@fusion.com) + + * ccbase.c, ccdefault.c: added window INTERFACE keyword. + * Makefile.in: made to work on the PC. + Tue Feb 28 00:35:33 1995 John Gilmore (gnu at toad.com) * ccbase.c, ccdefault.c: Avoid includes. diff --git a/src/lib/krb5/ccache/Makefile.in b/src/lib/krb5/ccache/Makefile.in index dcf8bb294..856726192 100644 --- a/src/lib/krb5/ccache/Makefile.in +++ b/src/lib/krb5/ccache/Makefile.in @@ -1,12 +1,35 @@ CFLAGS = $(CCOPTS) $(DEFS) LDFLAGS = -g -all:: $(OBJS) +##DOSBUILDTOP = ..\..\.. +##DOSLIBNAME=..\krb5.lib +##DOS!include $(BUILDTOP)\config\windows.in -OBJS= ccbase.o \ - ccdefault.o \ - ccdefops.o +OBJS= ccbase.$(OBJEXT) \ + ccdefault.$(OBJEXT) \ + ccdefops.$(OBJEXT) SRCS= $(srcdir)/ccbase.c \ $(srcdir)/ccdefault.c \ $(srcdir)/ccdefops.c + +all:: $(OBJS) all-$(WHAT) + +all-unix:: + +all-windows:: + cd FILE + @echo Making in CCACHE\FILE + -$(MAKE) -$(MFLAGS) LIBCMD=$(LIBCMD) + cd .. + +clean:: clean-$(WHAT) + +clean-unix:: + +clean-windows:: + cd FILE + @echo Making clean in CCACHE\FILE + -$(MAKE) -$(MFLAGS) clean + cd .. + diff --git a/src/lib/krb5/ccache/ccbase.c b/src/lib/krb5/ccache/ccbase.c index 6bdd049ef..c86212c32 100644 --- a/src/lib/krb5/ccache/ccbase.c +++ b/src/lib/krb5/ccache/ccbase.c @@ -39,7 +39,7 @@ static struct krb5_cc_typelist *cc_typehead = 0; * If override is set, replace any existing ccache with that type tag */ -krb5_error_code +krb5_error_code INTERFACE krb5_cc_register(context, ops, override) krb5_context context; krb5_cc_ops *ops; @@ -73,7 +73,8 @@ krb5_cc_register(context, ops, override) * particular cache type. */ -krb5_error_code krb5_cc_resolve (context, name, cache) +krb5_error_code INTERFACE +krb5_cc_resolve (context, name, cache) krb5_context context; char *name; krb5_ccache *cache; diff --git a/src/lib/krb5/ccache/ccdefault.c b/src/lib/krb5/ccache/ccdefault.c index 7b7b0fb8d..c5b8f4c73 100644 --- a/src/lib/krb5/ccache/ccdefault.c +++ b/src/lib/krb5/ccache/ccdefault.c @@ -26,7 +26,8 @@ #include "k5-int.h" -krb5_error_code krb5_cc_default(context, ccache) +krb5_error_code INTERFACE +krb5_cc_default(context, ccache) krb5_context context; krb5_ccache *ccache; { diff --git a/src/lib/krb5/ccache/file/ChangeLog b/src/lib/krb5/ccache/file/ChangeLog index 1d39f944d..e360610c9 100644 --- a/src/lib/krb5/ccache/file/ChangeLog +++ b/src/lib/krb5/ccache/file/ChangeLog @@ -1,3 +1,11 @@ +Tue Mar 7 15:58:15 1995 Keith Vetter (keithv@fusion.com) + + * fcc.h: alwas pull in low-level i/o stuff for the PC. + * *.c, fcc-proto.h: added windows INTERFACE keyword. + * fcc_dest.c, fcc_init.c, fcc_maybe.c, fcc_nseq.c, fcc_read.c, + fcc_sseq.c, fcc_write.c: fixed up some int/long and + signed/unsigned problems. + Tue Feb 28 00:35:55 1995 John Gilmore (gnu at toad.com) * fcc.h, fcc_gennew.c, fcc_maybe.c: Avoid includes. diff --git a/src/lib/krb5/ccache/file/Makefile.in b/src/lib/krb5/ccache/file/Makefile.in index 1650eb8ad..a31077816 100644 --- a/src/lib/krb5/ccache/file/Makefile.in +++ b/src/lib/krb5/ccache/file/Makefile.in @@ -1,13 +1,17 @@ CFLAGS = $(CCOPTS) $(DEFS) LDFLAGS = -g -all:: $(OBJS) +##DOSBUILDTOP = ..\..\..\.. +##DOSLIBNAME=..\..\krb5.lib +##DOS!include $(BUILDTOP)\config\windows.in -OBJS = fcc_close.o fcc_destry.o fcc_eseq.o \ - fcc_gennew.o fcc_getnam.o fcc_gprin.o fcc_init.o \ - fcc_nseq.o fcc_read.o fcc_reslv.o fcc_retrv.o \ - fcc_sseq.o fcc_store.o fcc_skip.o fcc_ops.o fcc_write.o \ - fcc_sflags.o fcc_defops.o fcc_errs.o fcc_maybe.o +OBJS = fcc_close.$(OBJEXT) fcc_destry.$(OBJEXT) fcc_eseq.$(OBJEXT) \ + fcc_gennew.$(OBJEXT) fcc_getnam.$(OBJEXT) fcc_gprin.$(OBJEXT) \ + fcc_init.$(OBJEXT) fcc_nseq.$(OBJEXT) fcc_read.$(OBJEXT) \ + fcc_reslv.$(OBJEXT) fcc_retrv.$(OBJEXT) fcc_sseq.$(OBJEXT) \ + fcc_store.$(OBJEXT) fcc_skip.$(OBJEXT) fcc_ops.$(OBJEXT) \ + fcc_write.$(OBJEXT) fcc_sflags.$(OBJEXT) fcc_defops.$(OBJEXT) \ + fcc_errs.$(OBJEXT) fcc_maybe.$(OBJEXT) SRCS = $(srcdir)/fcc_close.c $(srcdir)/fcc_destry.c $(srcdir)/fcc_eseq.c \ $(srcdir)/fcc_gennew.c $(srcdir)/fcc_getnam.c $(srcdir)/fcc_gprin.c \ @@ -17,4 +21,5 @@ SRCS = $(srcdir)/fcc_close.c $(srcdir)/fcc_destry.c $(srcdir)/fcc_eseq.c \ $(srcdir)/fcc_write.c $(srcdir)/fcc_sflags.c $(srcdir)/fcc_defops.c \ $(srcdir)/fcc_errs.c $(srcdir)/fcc_maybe.c +all:: $(OBJS) diff --git a/src/lib/krb5/ccache/file/fcc-proto.h b/src/lib/krb5/ccache/file/fcc-proto.h index e7bee704e..26c605968 100644 --- a/src/lib/krb5/ccache/file/fcc-proto.h +++ b/src/lib/krb5/ccache/file/fcc-proto.h @@ -29,74 +29,74 @@ #define KRB5_FCC_PROTO__ /* fcc_close.c */ -krb5_error_code krb5_fcc_close +krb5_error_code INTERFACE krb5_fcc_close PROTOTYPE((krb5_context, krb5_ccache id )); /* fcc_defnam.c */ -char *krb5_fcc_default_name +char * INTERFACE krb5_fcc_default_name PROTOTYPE((krb5_context)); /* fcc_destry.c */ -krb5_error_code krb5_fcc_destroy +krb5_error_code INTERFACE krb5_fcc_destroy PROTOTYPE((krb5_context, krb5_ccache id )); /* fcc_eseq.c */ -krb5_error_code krb5_fcc_end_seq_get +krb5_error_code INTERFACE krb5_fcc_end_seq_get PROTOTYPE((krb5_context, krb5_ccache id , krb5_cc_cursor *cursor )); /* fcc_gennew.c */ -krb5_error_code krb5_fcc_generate_new +krb5_error_code INTERFACE krb5_fcc_generate_new PROTOTYPE((krb5_context, krb5_ccache *id )); /* fcc_getnam.c */ -char *krb5_fcc_get_name +char * INTERFACE krb5_fcc_get_name PROTOTYPE((krb5_context, krb5_ccache id )); /* fcc_gprin.c */ -krb5_error_code krb5_fcc_get_principal +krb5_error_code INTERFACE krb5_fcc_get_principal PROTOTYPE((krb5_context, krb5_ccache id , krb5_principal *princ )); /* fcc_init.c */ -krb5_error_code krb5_fcc_initialize +krb5_error_code INTERFACE krb5_fcc_initialize PROTOTYPE((krb5_context, krb5_ccache id , krb5_principal princ )); /* fcc_nseq.c */ -krb5_error_code krb5_fcc_next_cred +krb5_error_code INTERFACE krb5_fcc_next_cred PROTOTYPE((krb5_context, krb5_ccache id , krb5_cc_cursor *cursor , krb5_creds *creds )); /* fcc_read.c */ -krb5_error_code krb5_fcc_read_principal +krb5_error_code INTERFACE krb5_fcc_read_principal PROTOTYPE((krb5_context, krb5_ccache id , krb5_principal *princ )); -krb5_error_code krb5_fcc_read_keyblock +krb5_error_code INTERFACE krb5_fcc_read_keyblock PROTOTYPE((krb5_context, krb5_ccache id , krb5_keyblock *keyblock )); -krb5_error_code krb5_fcc_read_data +krb5_error_code INTERFACE krb5_fcc_read_data PROTOTYPE((krb5_context, krb5_ccache id , krb5_data *data )); -krb5_error_code krb5_fcc_read_int32 +krb5_error_code INTERFACE krb5_fcc_read_int32 PROTOTYPE((krb5_context, krb5_ccache id , krb5_int32 *i )); -krb5_error_code krb5_fcc_read_ui_2 +krb5_error_code INTERFACE krb5_fcc_read_ui_2 PROTOTYPE((krb5_context, krb5_ccache id , krb5_ui_2 *i )); -krb5_error_code krb5_fcc_read_octet +krb5_error_code INTERFACE krb5_fcc_read_octet PROTOTYPE((krb5_context, krb5_ccache id , krb5_octet *i )); -krb5_error_code krb5_fcc_read_times +krb5_error_code INTERFACE krb5_fcc_read_times PROTOTYPE((krb5_context, krb5_ccache id , krb5_ticket_times *t )); -krb5_error_code krb5_fcc_read_addrs +krb5_error_code INTERFACE krb5_fcc_read_addrs PROTOTYPE((krb5_context, krb5_ccache, krb5_address ***)); -krb5_error_code krb5_fcc_read_addr +krb5_error_code INTERFACE krb5_fcc_read_addr PROTOTYPE((krb5_context, krb5_ccache, krb5_address *)); -krb5_error_code krb5_fcc_read_authdata +krb5_error_code INTERFACE krb5_fcc_read_authdata PROTOTYPE((krb5_context, krb5_ccache , krb5_authdata ***)); -krb5_error_code krb5_fcc_read_authdatum +krb5_error_code INTERFACE krb5_fcc_read_authdatum PROTOTYPE((krb5_context, krb5_ccache , krb5_authdata *)); /* fcc_reslv.c */ -krb5_error_code krb5_fcc_resolve +krb5_error_code INTERFACE krb5_fcc_resolve PROTOTYPE((krb5_context, krb5_ccache *id , char *residual )); /* fcc_retrv.c */ -krb5_error_code krb5_fcc_retrieve +krb5_error_code INTERFACE krb5_fcc_retrieve PROTOTYPE((krb5_context, krb5_ccache id , krb5_flags whichfields , @@ -104,58 +104,58 @@ krb5_error_code krb5_fcc_retrieve krb5_creds *creds )); /* fcc_sseq.c */ -krb5_error_code krb5_fcc_start_seq_get +krb5_error_code INTERFACE krb5_fcc_start_seq_get PROTOTYPE((krb5_context, krb5_ccache id , krb5_cc_cursor *cursor )); /* fcc_store.c */ -krb5_error_code krb5_fcc_store +krb5_error_code INTERFACE krb5_fcc_store PROTOTYPE((krb5_context, krb5_ccache id , krb5_creds *creds )); /* fcc_skip.c */ -krb5_error_code krb5_fcc_skip_principal +krb5_error_code INTERFACE krb5_fcc_skip_principal PROTOTYPE((krb5_context, krb5_ccache id )); /* fcc_sflags.c */ -krb5_error_code krb5_fcc_set_flags +krb5_error_code INTERFACE krb5_fcc_set_flags PROTOTYPE((krb5_context, krb5_ccache id , krb5_flags flags )); /* fcc_ops.c */ extern krb5_cc_ops krb5_cc_file_ops; /* fcc_write.c */ -krb5_error_code krb5_fcc_write +krb5_error_code INTERFACE krb5_fcc_write PROTOTYPE((krb5_context, krb5_ccache id , krb5_pointer buf , int len )); -krb5_error_code krb5_fcc_store_principal +krb5_error_code INTERFACE krb5_fcc_store_principal PROTOTYPE((krb5_context, krb5_ccache id , krb5_principal princ )); -krb5_error_code krb5_fcc_store_keyblock +krb5_error_code INTERFACE krb5_fcc_store_keyblock PROTOTYPE((krb5_context, krb5_ccache id , krb5_keyblock *keyblock )); -krb5_error_code krb5_fcc_store_data +krb5_error_code INTERFACE krb5_fcc_store_data PROTOTYPE((krb5_context, krb5_ccache id , krb5_data *data )); -krb5_error_code krb5_fcc_store_int32 +krb5_error_code INTERFACE krb5_fcc_store_int32 PROTOTYPE((krb5_context, krb5_ccache id , krb5_int32 i )); -krb5_error_code krb5_fcc_store_ui_2 +krb5_error_code INTERFACE krb5_fcc_store_ui_2 PROTOTYPE((krb5_context, krb5_ccache id , krb5_int32 i )); -krb5_error_code krb5_fcc_store_octet +krb5_error_code INTERFACE krb5_fcc_store_octet PROTOTYPE((krb5_context, krb5_ccache id , krb5_int32 i )); -krb5_error_code krb5_fcc_store_times +krb5_error_code INTERFACE krb5_fcc_store_times PROTOTYPE((krb5_context, krb5_ccache id , krb5_ticket_times *t )); -krb5_error_code krb5_fcc_store_addrs +krb5_error_code INTERFACE krb5_fcc_store_addrs PROTOTYPE((krb5_context, krb5_ccache , krb5_address ** )); -krb5_error_code krb5_fcc_store_addr +krb5_error_code INTERFACE krb5_fcc_store_addr PROTOTYPE((krb5_context, krb5_ccache , krb5_address * )); -krb5_error_code krb5_fcc_store_authdata +krb5_error_code INTERFACE krb5_fcc_store_authdata PROTOTYPE((krb5_context, krb5_ccache , krb5_authdata **)); -krb5_error_code krb5_fcc_store_authdatum +krb5_error_code INTERFACE krb5_fcc_store_authdatum PROTOTYPE((krb5_context, krb5_ccache , krb5_authdata *)); /* fcc_errs.c */ -krb5_error_code krb5_fcc_interpret +krb5_error_code INTERFACE krb5_fcc_interpret PROTOTYPE((krb5_context, int )); /* fcc_maybe.c */ -krb5_error_code krb5_fcc_close_file +krb5_error_code INTERFACE krb5_fcc_close_file PROTOTYPE((krb5_context, krb5_ccache)); -krb5_error_code krb5_fcc_open_file +krb5_error_code INTERFACE krb5_fcc_open_file PROTOTYPE((krb5_context, krb5_ccache, int)); #endif /* KRB5_FCC_PROTO__ */ diff --git a/src/lib/krb5/ccache/file/fcc.h b/src/lib/krb5/ccache/file/fcc.h index 83686c56e..6b7c1b8b7 100644 --- a/src/lib/krb5/ccache/file/fcc.h +++ b/src/lib/krb5/ccache/file/fcc.h @@ -28,6 +28,7 @@ #ifndef __KRB5_FILE_CCACHE__ #define __KRB5_FILE_CCACHE__ +#define NEED_LOWLEVEL_IO #include "k5-int.h" #include "fcc-proto.h" #include diff --git a/src/lib/krb5/ccache/file/fcc_close.c b/src/lib/krb5/ccache/file/fcc_close.c index d59516e4d..4c549aa3f 100644 --- a/src/lib/krb5/ccache/file/fcc_close.c +++ b/src/lib/krb5/ccache/file/fcc_close.c @@ -27,7 +27,7 @@ #include "fcc.h" - +#include /* * Modifies: * id @@ -36,7 +36,7 @@ * Closes the file cache, invalidates the id, and frees any resources * associated with the cache. */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_close(context, id) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_defnam.c b/src/lib/krb5/ccache/file/fcc_defnam.c index 5926aca9f..1982b37bf 100644 --- a/src/lib/krb5/ccache/file/fcc_defnam.c +++ b/src/lib/krb5/ccache/file/fcc_defnam.c @@ -48,7 +48,7 @@ static char krb5_default_name_string[KRB5_FCC_MAXLEN] = ""; * returned is to static storage; the name must be copied elsewhere. */ -char * +char * INTERFACE krb5_fcc_default_name (context) krb5_context context; { diff --git a/src/lib/krb5/ccache/file/fcc_destry.c b/src/lib/krb5/ccache/file/fcc_destry.c index 9fb13f63e..ad8dbcc3c 100644 --- a/src/lib/krb5/ccache/file/fcc_destry.c +++ b/src/lib/krb5/ccache/file/fcc_destry.c @@ -24,7 +24,6 @@ * This file contains the source code for krb5_fcc_destroy. */ - #include #include "fcc.h" @@ -35,19 +34,23 @@ * Errors: * system errors */ -krb5_error_code krb5_fcc_destroy(context, id) +krb5_error_code INTERFACE +krb5_fcc_destroy(context, id) krb5_context context; krb5_ccache id; { struct stat buf; - unsigned long size; + unsigned long i, size; + unsigned int wlen; char zeros[BUFSIZ]; - register int ret, i; + register int ret; + krb5_error_code kret; + if (OPENCLOSE(id)) { ret = open(((krb5_fcc_data *) id->data)->filename, O_RDWR, 0); if (ret < 0) { - ret = krb5_fcc_interpret(context, errno); + kret = krb5_fcc_interpret(context, errno); goto cleanup; } ((krb5_fcc_data *) id->data)->fd = ret; @@ -57,17 +60,18 @@ krb5_error_code krb5_fcc_destroy(context, id) ret = unlink(((krb5_fcc_data *) id->data)->filename); if (ret < 0) { - ret = krb5_fcc_interpret(context, errno); + kret = krb5_fcc_interpret(context, errno); if (OPENCLOSE(id)) { (void) close(((krb5_fcc_data *)id->data)->fd); ((krb5_fcc_data *) id->data)->fd = -1; + kret = ret; } goto cleanup; } ret = fstat(((krb5_fcc_data *) id->data)->fd, &buf); if (ret < 0) { - ret = krb5_fcc_interpret(context, errno); + kret = krb5_fcc_interpret(context, errno); if (OPENCLOSE(id)) { (void) close(((krb5_fcc_data *)id->data)->fd); ((krb5_fcc_data *) id->data)->fd = -1; @@ -81,7 +85,7 @@ krb5_error_code krb5_fcc_destroy(context, id) memset(zeros, 0, BUFSIZ); for (i=0; i < size / BUFSIZ; i++) if (write(((krb5_fcc_data *) id->data)->fd, zeros, BUFSIZ) < 0) { - ret = krb5_fcc_interpret(context, errno); + kret = krb5_fcc_interpret(context, errno); if (OPENCLOSE(id)) { (void) close(((krb5_fcc_data *)id->data)->fd); ((krb5_fcc_data *) id->data)->fd = -1; @@ -89,8 +93,9 @@ krb5_error_code krb5_fcc_destroy(context, id) goto cleanup; } - if (write(((krb5_fcc_data *) id->data)->fd, zeros, size % BUFSIZ) < 0) { - ret = krb5_fcc_interpret(context, errno); + wlen = (unsigned int) (size % BUFSIZ); + if (write(((krb5_fcc_data *) id->data)->fd, zeros, wlen) < 0) { + kret = krb5_fcc_interpret(context, errno); if (OPENCLOSE(id)) { (void) close(((krb5_fcc_data *)id->data)->fd); ((krb5_fcc_data *) id->data)->fd = -1; @@ -102,12 +107,12 @@ krb5_error_code krb5_fcc_destroy(context, id) ((krb5_fcc_data *) id->data)->fd = -1; if (ret) - ret = krb5_fcc_interpret(context, errno); + kret = krb5_fcc_interpret(context, errno); cleanup: krb5_xfree(((krb5_fcc_data *) id->data)->filename); krb5_xfree(id->data); krb5_xfree(id); - return ret; + return kret; } diff --git a/src/lib/krb5/ccache/file/fcc_errs.c b/src/lib/krb5/ccache/file/fcc_errs.c index 8a4834ab1..43d8525dc 100644 --- a/src/lib/krb5/ccache/file/fcc_errs.c +++ b/src/lib/krb5/ccache/file/fcc_errs.c @@ -28,12 +28,12 @@ #include "fcc.h" -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_interpret(context, errnum) krb5_context context; int errnum; { - register int retval; + register krb5_error_code retval; switch (errnum) { case ENOENT: retval = KRB5_FCC_NOFILE; diff --git a/src/lib/krb5/ccache/file/fcc_eseq.c b/src/lib/krb5/ccache/file/fcc_eseq.c index d2b5f1f8d..d888aa995 100644 --- a/src/lib/krb5/ccache/file/fcc_eseq.c +++ b/src/lib/krb5/ccache/file/fcc_eseq.c @@ -40,7 +40,7 @@ * and invalidates the cursor (it must never be used after this call). */ /* ARGSUSED */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_end_seq_get(context, id, cursor) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_gennew.c b/src/lib/krb5/ccache/file/fcc_gennew.c index 099e4002a..507893350 100644 --- a/src/lib/krb5/ccache/file/fcc_gennew.c +++ b/src/lib/krb5/ccache/file/fcc_gennew.c @@ -24,13 +24,15 @@ * This file contains the source code for krb5_fcc_generate_new. */ - +#define NEED_SOCKETS #include -#include "k5-int.h" #include "fcc.h" +#include "k5-int.h" #ifdef KRB5_USE_INET +#ifndef _WINSOCKAPI_ #include +#endif #else #error find some way to use net-byte-order file version numbers. #endif @@ -51,7 +53,7 @@ extern krb5_cc_ops krb5_fcc_ops; * krb5_ccache. id is undefined. * system errors (from open) */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_generate_new (context, id) krb5_context context; krb5_ccache *id; diff --git a/src/lib/krb5/ccache/file/fcc_getnam.c b/src/lib/krb5/ccache/file/fcc_getnam.c index f3357f101..8422ff6d2 100644 --- a/src/lib/krb5/ccache/file/fcc_getnam.c +++ b/src/lib/krb5/ccache/file/fcc_getnam.c @@ -35,7 +35,7 @@ * Returns: * The name of the file cred cache id. */ -char * +char * INTERFACE krb5_fcc_get_name (context, id) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_gprin.c b/src/lib/krb5/ccache/file/fcc_gprin.c index a97abd62e..fbd35ff85 100644 --- a/src/lib/krb5/ccache/file/fcc_gprin.c +++ b/src/lib/krb5/ccache/file/fcc_gprin.c @@ -40,7 +40,7 @@ * system errors * KRB5_CC_NOMEM */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_get_principal(context, id, princ) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_init.c b/src/lib/krb5/ccache/file/fcc_init.c index fffc09a88..c78d416af 100644 --- a/src/lib/krb5/ccache/file/fcc_init.c +++ b/src/lib/krb5/ccache/file/fcc_init.c @@ -40,30 +40,31 @@ * system errors * permission errors */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_initialize(context, id, princ) krb5_context context; krb5_ccache id; krb5_principal princ; { - int ret = KRB5_OK; + krb5_error_code kret; + int reti; MAYBE_OPEN(context, id, FCC_OPEN_AND_ERASE); #ifdef NOFCHMOD - ret = chmod(((krb5_fcc_data *) id->data)->filename, S_IREAD | S_IWRITE); + reti = chmod(((krb5_fcc_data *) id->data)->filename, S_IREAD | S_IWRITE); #else - ret = fchmod(((krb5_fcc_data *) id->data)->fd, S_IREAD | S_IWRITE); + reti = fchmod(((krb5_fcc_data *) id->data)->fd, S_IREAD | S_IWRITE); #endif - if (ret == -1) { - ret = krb5_fcc_interpret(context, errno); - MAYBE_CLOSE(context, id, ret); - return ret; + if (reti == -1) { + kret = krb5_fcc_interpret(context, errno); + MAYBE_CLOSE(context, id, kret); + return kret; } krb5_fcc_store_principal(context, id, princ); - MAYBE_CLOSE(context, id, ret); - return ret; + MAYBE_CLOSE(context, id, kret); + return kret; } diff --git a/src/lib/krb5/ccache/file/fcc_maybe.c b/src/lib/krb5/ccache/file/fcc_maybe.c index 1c4c72904..274c651c7 100644 --- a/src/lib/krb5/ccache/file/fcc_maybe.c +++ b/src/lib/krb5/ccache/file/fcc_maybe.c @@ -24,6 +24,7 @@ * This file contains the source code for conditional open/close calls. */ +#define NEED_SOCKETS /* Only for ntohs, etc. */ #if HAVE_UNISTD_H #include #endif @@ -35,7 +36,9 @@ int krb5_fcc_default_format = KRB5_FCC_DEFAULT_FVNO; #ifdef KRB5_USE_INET +#ifndef _WINSOCKAPI_ #include +#endif #else #error find some way to use net-byte-order file version numbers. #endif @@ -156,7 +159,7 @@ int lockunlock; #undef EXCLUSIVE_LOCK #undef UNLOCK_LOCK -#endif HAVE_FLOCK +#endif /* HAVE_FLOCK */ static krb5_error_code fcc_lock_file PROTOTYPE((krb5_fcc_data *, int, int)); static krb5_error_code @@ -180,7 +183,7 @@ int lockunlock; #endif } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_close_file (context, id) krb5_context context; krb5_ccache id; @@ -201,14 +204,14 @@ krb5_fcc_close_file (context, id) return (ret == -1) ? krb5_fcc_interpret (context, errno) : 0; } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_open_file (context, id, mode) krb5_context context; krb5_ccache id; int mode; { krb5_fcc_data *data = (krb5_fcc_data *)id->data; - krb5_int16 fcc_fvno; + krb5_ui_2 fcc_fvno; int fd; int open_flag; krb5_error_code retval; diff --git a/src/lib/krb5/ccache/file/fcc_nseq.c b/src/lib/krb5/ccache/file/fcc_nseq.c index 1a85acd0a..96650ac45 100644 --- a/src/lib/krb5/ccache/file/fcc_nseq.c +++ b/src/lib/krb5/ccache/file/fcc_nseq.c @@ -48,7 +48,7 @@ * Errors: * system errors */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_next_cred(context, id, cursor, creds) krb5_context context; krb5_ccache id; @@ -56,7 +56,6 @@ krb5_fcc_next_cred(context, id, cursor, creds) krb5_creds *creds; { #define TCHECK(ret) if (ret != KRB5_OK) goto lose; - int ret; krb5_error_code kret; krb5_fcc_cursor *fcursor; krb5_int32 int32; @@ -68,11 +67,11 @@ krb5_fcc_next_cred(context, id, cursor, creds) fcursor = (krb5_fcc_cursor *) *cursor; - ret = lseek(((krb5_fcc_data *) id->data)->fd, fcursor->pos, SEEK_SET); - if (ret < 0) { - ret = krb5_fcc_interpret(context, errno); - MAYBE_CLOSE(context, id, ret); - return ret; + kret = lseek(((krb5_fcc_data *) id->data)->fd, fcursor->pos, SEEK_SET); + if (kret < 0) { + kret = krb5_fcc_interpret(context, errno); + MAYBE_CLOSE(context, id, kret); + return kret; } kret = krb5_fcc_read_principal(context, id, &creds->client); diff --git a/src/lib/krb5/ccache/file/fcc_read.c b/src/lib/krb5/ccache/file/fcc_read.c index 0ff983a30..bf4c871f0 100644 --- a/src/lib/krb5/ccache/file/fcc_read.c +++ b/src/lib/krb5/ccache/file/fcc_read.c @@ -40,7 +40,7 @@ * KRB5_CC_END - there were not len bytes available * system errors (read) */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_read(context, id, buf, len) krb5_context context; krb5_ccache id; @@ -75,7 +75,7 @@ krb5_fcc_read(context, id, buf, len) * KRB5_CC_NOMEM */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_read_principal(context, id, princ) krb5_context context; krb5_ccache id; @@ -84,7 +84,7 @@ krb5_fcc_read_principal(context, id, princ) krb5_fcc_data *data = (krb5_fcc_data *)id->data; krb5_error_code kret; register krb5_principal tmpprinc; - krb5_int32 length, type; + krb5_int32 length, type, msize; int i; if (data->version == KRB5_FCC_FVNO_1) { @@ -112,8 +112,11 @@ krb5_fcc_read_principal(context, id, princ) if (tmpprinc == NULL) return KRB5_CC_NOMEM; if (length) { - tmpprinc->data = (krb5_data *) malloc(length * sizeof(krb5_data)); - if (tmpprinc->data == 0) { + tmpprinc->data = 0; + msize = length * sizeof(krb5_data); + if ((msize & VALID_UINT_BITS) == msize) /* Not overflow size_t */ + tmpprinc->data = (krb5_data *) malloc((size_t) msize); + if (tmpprinc->data == (krb5_data *) 0) { free((char *)tmpprinc); return KRB5_CC_NOMEM; } @@ -143,14 +146,14 @@ krb5_fcc_read_principal(context, id, princ) return kret; } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_read_addrs(context, id, addrs) krb5_context context; krb5_ccache id; krb5_address ***addrs; { krb5_error_code kret; - krb5_int32 length; + krb5_int32 length, msize; int i; *addrs = 0; @@ -162,7 +165,10 @@ krb5_fcc_read_addrs(context, id, addrs) /* Make *addrs able to hold length pointers to krb5_address structs * Add one extra for a null-terminated list */ - *addrs = (krb5_address **) calloc(length+1, sizeof(krb5_address *)); + msize = length+1; + if ((msize & VALID_UINT_BITS) != msize) /* Overflow size_t??? */ + return KRB5_CC_NOMEM; + *addrs = (krb5_address **) calloc((size_t) msize, sizeof(krb5_address *)); if (*addrs == NULL) return KRB5_CC_NOMEM; @@ -183,7 +189,7 @@ krb5_fcc_read_addrs(context, id, addrs) return kret; } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_read_keyblock(context, id, keyblock) krb5_context context; krb5_ccache id; @@ -211,7 +217,9 @@ krb5_fcc_read_keyblock(context, id, keyblock) kret = krb5_fcc_read_int32(context, id, &int32); CHECK(kret); - keyblock->length = int32; + if ((int32 & VALID_INT_BITS) != int32) /* Overflow size_t??? */ + return KRB5_CC_NOMEM; + keyblock->length = (int) int32; if ( keyblock->length == 0 ) return KRB5_OK; keyblock->contents = (unsigned char *) malloc(keyblock->length* @@ -230,19 +238,23 @@ krb5_fcc_read_keyblock(context, id, keyblock) return kret; } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_read_data(context, id, data) krb5_context context; krb5_ccache id; krb5_data *data; { krb5_error_code kret; + krb5_int32 len; data->magic = KV5M_DATA; data->data = 0; - kret = krb5_fcc_read_int32(context, id, &data->length); + kret = krb5_fcc_read_int32(context, id, &len); CHECK(kret); + if ((len & VALID_INT_BITS) != len) + return KRB5_CC_NOMEM; + data->length = (int) len; if (data->length == 0) { data->data = 0; @@ -264,7 +276,7 @@ krb5_fcc_read_data(context, id, data) return kret; } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_read_addr(context, id, addr) krb5_context context; krb5_ccache id; @@ -283,7 +295,9 @@ krb5_fcc_read_addr(context, id, addr) kret = krb5_fcc_read_int32(context, id, &int32); CHECK(kret); - addr->length = int32; + if ((int32 & VALID_INT_BITS) != int32) /* Overflow int??? */ + return KRB5_CC_NOMEM; + addr->length = (int) int32; if (addr->length == 0) return KRB5_OK; @@ -302,7 +316,7 @@ krb5_fcc_read_addr(context, id, addr) return kret; } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_read_int32(context, id, i) krb5_context context; krb5_ccache id; @@ -324,7 +338,7 @@ krb5_fcc_read_int32(context, id, i) } } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_read_ui_2(context, id, i) krb5_context context; krb5_ccache id; @@ -346,7 +360,7 @@ krb5_fcc_read_ui_2(context, id, i) } } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_read_octet(context, id, i) krb5_context context; krb5_ccache id; @@ -356,7 +370,7 @@ krb5_fcc_read_octet(context, id, i) } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_read_times(context, id, t) krb5_context context; krb5_ccache id; @@ -391,14 +405,14 @@ errout: return retval; } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_read_authdata(context, id, a) krb5_context context; krb5_ccache id; krb5_authdata ***a; { krb5_error_code kret; - krb5_int32 length; + krb5_int32 length, msize; int i; *a = 0; @@ -413,7 +427,10 @@ krb5_fcc_read_authdata(context, id, a) /* Make *a able to hold length pointers to krb5_authdata structs * Add one extra for a null-terminated list */ - *a = (krb5_authdata **) calloc(length+1, sizeof(krb5_authdata *)); + msize = length+1; + if ((msize & VALID_UINT_BITS) != msize) /* Overflow size_t??? */ + return KRB5_CC_NOMEM; + *a = (krb5_authdata **) calloc((size_t) msize, sizeof(krb5_authdata *)); if (*a == NULL) return KRB5_CC_NOMEM; @@ -434,7 +451,7 @@ krb5_fcc_read_authdata(context, id, a) return kret; } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_read_authdatum(context, id, a) krb5_context context; krb5_ccache id; @@ -443,7 +460,6 @@ krb5_fcc_read_authdatum(context, id, a) krb5_error_code kret; krb5_int32 int32; krb5_ui_2 ui2; - int ret; a->magic = KV5M_AUTHDATA; a->contents = NULL; @@ -453,7 +469,9 @@ krb5_fcc_read_authdatum(context, id, a) a->ad_type = (krb5_authdatatype)ui2; kret = krb5_fcc_read_int32(context, id, &int32); CHECK(kret); - a->length = int32; + if ((int32 & VALID_INT_BITS) != int32) /* Overflow int??? */ + return KRB5_CC_NOMEM; + a->length = (int) int32; if (a->length == 0 ) return KRB5_OK; diff --git a/src/lib/krb5/ccache/file/fcc_reslv.c b/src/lib/krb5/ccache/file/fcc_reslv.c index 2944f43bb..c352c0c0b 100644 --- a/src/lib/krb5/ccache/file/fcc_reslv.c +++ b/src/lib/krb5/ccache/file/fcc_reslv.c @@ -49,7 +49,7 @@ extern krb5_cc_ops krb5_fcc_ops; * krb5_ccache. id is undefined. * permission errors */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_resolve (context, id, residual) krb5_context context; krb5_ccache *id; diff --git a/src/lib/krb5/ccache/file/fcc_retrv.c b/src/lib/krb5/ccache/file/fcc_retrv.c index b9d324224..32ee4960b 100644 --- a/src/lib/krb5/ccache/file/fcc_retrv.c +++ b/src/lib/krb5/ccache/file/fcc_retrv.c @@ -84,7 +84,7 @@ register const krb5_data *data1, *data2; * permission errors * KRB5_CC_NOMEM */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_retrieve(context, id, whichfields, mcreds, creds) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_sflags.c b/src/lib/krb5/ccache/file/fcc_sflags.c index ac4b5a96f..d74f2b0e8 100644 --- a/src/lib/krb5/ccache/file/fcc_sflags.c +++ b/src/lib/krb5/ccache/file/fcc_sflags.c @@ -39,7 +39,7 @@ * Effects: * Sets the operational flags of id to flags. */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_set_flags(context, id, flags) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_skip.c b/src/lib/krb5/ccache/file/fcc_skip.c index 15aa43bd2..f4db9b3f8 100644 --- a/src/lib/krb5/ccache/file/fcc_skip.c +++ b/src/lib/krb5/ccache/file/fcc_skip.c @@ -28,7 +28,7 @@ #include "fcc.h" -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_skip_principal(context, id) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_sseq.c b/src/lib/krb5/ccache/file/fcc_sseq.c index 622cd5701..c2d1645c1 100644 --- a/src/lib/krb5/ccache/file/fcc_sseq.c +++ b/src/lib/krb5/ccache/file/fcc_sseq.c @@ -40,23 +40,23 @@ * KRB5_CC_NOMEM * system errors */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_start_seq_get(context, id, cursor) krb5_context context; krb5_ccache id; krb5_cc_cursor *cursor; { krb5_fcc_cursor *fcursor; - int ret = KRB5_OK; + krb5_error_code kret = KRB5_OK; fcursor = (krb5_fcc_cursor *) malloc(sizeof(krb5_fcc_cursor)); if (fcursor == NULL) return KRB5_CC_NOMEM; if (OPENCLOSE(id)) { - ret = krb5_fcc_open_file(context, id, FCC_OPEN_RDONLY); - if (ret) { + kret = krb5_fcc_open_file(context, id, FCC_OPEN_RDONLY); + if (kret) { krb5_xfree(fcursor); - return ret; + return kret; } } else @@ -69,6 +69,6 @@ krb5_fcc_start_seq_get(context, id, cursor) fcursor->pos = lseek(((krb5_fcc_data *) id->data)->fd, 0, SEEK_CUR); *cursor = (krb5_cc_cursor) fcursor; - MAYBE_CLOSE(context, id, ret); - return ret; + MAYBE_CLOSE(context, id, kret); + return kret; } diff --git a/src/lib/krb5/ccache/file/fcc_store.c b/src/lib/krb5/ccache/file/fcc_store.c index 352cae763..12eef45bf 100644 --- a/src/lib/krb5/ccache/file/fcc_store.c +++ b/src/lib/krb5/ccache/file/fcc_store.c @@ -41,7 +41,7 @@ * system errors * storage failure errors */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_store(context, id, creds) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_write.c b/src/lib/krb5/ccache/file/fcc_write.c index f5c8f8c30..e433bff7a 100644 --- a/src/lib/krb5/ccache/file/fcc_write.c +++ b/src/lib/krb5/ccache/file/fcc_write.c @@ -41,7 +41,7 @@ * Errors: * system errors */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_write(context, id, buf, len) krb5_context context; krb5_ccache id; @@ -72,7 +72,7 @@ krb5_fcc_write(context, id, buf, len) * system errors */ -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_store_principal(context, id, princ) krb5_context context; krb5_ccache id; @@ -111,7 +111,7 @@ krb5_fcc_store_principal(context, id, princ) return KRB5_OK; } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_store_addrs(context, id, addrs) krb5_context context; krb5_ccache id; @@ -138,7 +138,7 @@ krb5_fcc_store_addrs(context, id, addrs) return KRB5_OK; } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_store_keyblock(context, id, keyblock) krb5_context context; krb5_ccache id; @@ -159,7 +159,7 @@ krb5_fcc_store_keyblock(context, id, keyblock) return krb5_fcc_write(context, id, (char *) keyblock->contents, keyblock->length); } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_store_addr(context, id, addr) krb5_context context; krb5_ccache id; @@ -175,7 +175,7 @@ krb5_fcc_store_addr(context, id, addr) } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_store_data(context, id, data) krb5_context context; krb5_ccache id; @@ -188,7 +188,7 @@ krb5_fcc_store_data(context, id, data) return krb5_fcc_write(context, id, data->data, data->length); } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_store_int32(context, id, i) krb5_context context; krb5_ccache id; @@ -201,19 +201,19 @@ krb5_fcc_store_int32(context, id, i) (data->version == KRB5_FCC_FVNO_2)) return krb5_fcc_write(context, id, (char *) &i, sizeof(krb5_int32)); else { - buf[3] = i & 0xFF; + buf[3] = (unsigned char) (i & 0xFF); i >>= 8; - buf[2] = i & 0xFF; + buf[2] = (unsigned char) (i & 0xFF); i >>= 8; - buf[1] = i & 0xFF; + buf[1] = (unsigned char) (i & 0xFF); i >>= 8; - buf[0] = i & 0xFF; + buf[0] = (unsigned char) (i & 0xFF); return krb5_fcc_write(context, id, buf, 4); } } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_store_ui_2(context, id, i) krb5_context context; krb5_ccache id; @@ -225,18 +225,18 @@ krb5_fcc_store_ui_2(context, id, i) if ((data->version == KRB5_FCC_FVNO_1) || (data->version == KRB5_FCC_FVNO_2)) { - ibuf = i; + ibuf = (krb5_ui_2) i; return krb5_fcc_write(context, id, (char *) &ibuf, sizeof(krb5_ui_2)); } else { - buf[1] = i & 0xFF; + buf[1] = (unsigned char) (i & 0xFF); i >>= 8; - buf[0] = i & 0xFF; + buf[0] = (unsigned char) (i & 0xFF); return krb5_fcc_write(context, id, buf, 2); } } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_store_octet(context, id, i) krb5_context context; krb5_ccache id; @@ -244,11 +244,11 @@ krb5_fcc_store_octet(context, id, i) { krb5_octet ibuf; - ibuf = i; + ibuf = (krb5_octet) i; return krb5_fcc_write(context, id, (char *) &ibuf, 1); } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_store_times(context, id, t) krb5_context context; krb5_ccache id; @@ -273,7 +273,7 @@ krb5_fcc_store_times(context, id, t) } } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_store_authdata(context, id, a) krb5_context context; krb5_ccache id; @@ -297,7 +297,7 @@ krb5_fcc_store_authdata(context, id, a) return KRB5_OK; } -krb5_error_code +krb5_error_code INTERFACE krb5_fcc_store_authdatum (context, id, a) krb5_context context; krb5_ccache id; -- 2.26.2