From 61bcf2d3cf4bc245c7812adf88287f456fa19e57 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Sat, 29 Sep 2007 00:01:17 +0000 Subject: [PATCH] pull up r19891 from trunk r19891@cathode-dark-space: jaltman | 2007-08-28 16:58:45 -0400 ticket: new subject: NIM: 64-bit Windows Support and Removal of Compile Time Warnings component: windows This patch permits Network Identity Manager to be built for 64-bit Windows. In the process all compile time warnings have been taken care of. For 64-bit Windows, we do not build the Kerberos v4 Credential Provider and we will not attempt to load the krb524 library. Note that when testing the 64-bit NIM, there is no CCAPI at the moment so you must manually specify a FILE: ccache as part of the identity's Kerberos v5 configuration if you want to use cache's other than the MSLSA. This patch also consolidates the computation of the default ccache name into utility functions: khm_krb5_get_identity_default_ccache khm_krb5_get_identity_default_ccacheA ticket: 5696 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@20005 dc483132-0cff-0310-8789-dd5450dbe970 --- src/windows/identity/Makefile | 424 +++++++++--------- src/windows/identity/kcreddb/credential.c | 10 +- src/windows/identity/kcreddb/credset.c | 29 +- src/windows/identity/kcreddb/identity.c | 14 +- src/windows/identity/kcreddb/kcreddb.h | 2 +- src/windows/identity/kherr/kherr.c | 185 ++++---- src/windows/identity/kherr/kherr.h | 2 +- src/windows/identity/kmm/kmm.c | 4 +- src/windows/identity/kmm/kmm_module.c | 30 +- src/windows/identity/kmm/kmm_reg.c | 2 +- src/windows/identity/kmm/kmm_registrar.c | 20 +- src/windows/identity/kmm/kmminternal.h | 1 + src/windows/identity/kmq/consumer.c | 10 +- src/windows/identity/kmq/init.c | 3 - .../identity/plugins/common/dynimport.c | 8 +- .../identity/plugins/common/dynimport.h | 6 +- .../identity/plugins/krb4/krb4configdlg.c | 4 +- src/windows/identity/plugins/krb4/krb4funcs.c | 8 +- .../identity/plugins/krb5/krb5configdlg.c | 6 +- .../identity/plugins/krb5/krb5configid.c | 36 +- src/windows/identity/plugins/krb5/krb5funcs.c | 153 ++++--- src/windows/identity/plugins/krb5/krb5funcs.h | 6 + .../identity/plugins/krb5/krb5identpro.c | 5 +- .../identity/plugins/krb5/krb5newcreds.c | 133 +++++- src/windows/identity/ui/addrchange.c | 1 - src/windows/identity/ui/cfg_appear_wnd.c | 2 +- src/windows/identity/ui/cfg_general_wnd.c | 4 +- src/windows/identity/ui/cfg_plugins_wnd.c | 2 +- src/windows/identity/ui/configwnd.c | 2 +- src/windows/identity/ui/credwnd.c | 77 ++-- src/windows/identity/ui/debugfuncs.c | 2 +- src/windows/identity/ui/htwnd.c | 18 +- src/windows/identity/ui/main.c | 14 +- src/windows/identity/ui/mainmenu.c | 2 +- src/windows/identity/ui/mainwnd.c | 16 +- src/windows/identity/ui/newcredwnd.c | 2 +- src/windows/identity/ui/notifier.c | 21 +- src/windows/identity/uilib/action.c | 12 +- src/windows/identity/uilib/creddlg.c | 3 +- src/windows/identity/uilib/khaction.h | 2 +- 40 files changed, 713 insertions(+), 568 deletions(-) diff --git a/src/windows/identity/Makefile b/src/windows/identity/Makefile index 375bdce15..a2fdcf449 100644 --- a/src/windows/identity/Makefile +++ b/src/windows/identity/Makefile @@ -1,210 +1,214 @@ -# -# Copyright (c) 2004 Massachusetts Institute of Technology -# Copyright (c) 2006 Secure Endpoints Inc. -# -# Permission is hereby granted, free of charge, to any person -# obtaining a copy of this software and associated documentation files -# (the "Software"), to deal in the Software without restriction, -# including without limitation the rights to use, copy, modify, merge, -# publish, distribute, sublicense, and/or sell copies of the Software, -# and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -!ifdef ETAGRUN -all: finale doc -!else -all: finale -!endif - -MODULE=all -!include - -!ifndef CLEANRUN -!ifndef TESTRUN -!ifndef ETAGRUN - -# Define KH_NO_WX if the build should not fail on warnings. The -# default is to treat warnings as errors. - -#RMAKE=$(MAKECMD) /nologo all KH_NO_WX=1 -RMAKE=$(MAKECMD) /nologo all -RMAKE_W2K=$(MAKECMD) /nologo all KHBUILD_W2K=1 - -!else -RMAKE=$(MAKECMD) /nologo etag -RMAKE_W2K=echo Skipping W2K target for ETAGS run. -!endif -!else -RMAKE=$(MAKECMD) /nologo test -RMAKE_W2K=$(MAKECMD) /nologo test KHBUILD_W2K=1 -!endif -!else -RMAKE=$(MAKECMD) /nologo clean -RMAKE_W2K=$(MAKECMD) /nologo clean KHBUILD_W2K=1 -!endif - -start: - -config: start - $(ECHO) -- Entering $@: - $(CD) $@ - $(RMAKE) - $(CD) .. - $(ECHO) -- Done with $@ - -include: config - $(ECHO) -- Entering $@: - $(CD) $@ - $(RMAKE) - $(CD) .. - $(ECHO) -- Done with $@ - -util: include - $(ECHO) -- Entering $@: - $(CD) $@ - $(RMAKE) - $(CD) .. - $(ECHO) -- Done with $@ - -kherr: util - $(ECHO) -- Entering $@: - $(CD) $@ - $(RMAKE) - $(CD) .. - $(ECHO) -- Done with $@ - -kconfig: kherr - $(ECHO) -- Entering $@: - $(CD) $@ - $(RMAKE) - $(CD) .. - $(ECHO) -- Done with $@ - -kmq: kconfig - $(ECHO) -- Entering $@: - $(CD) $@ - $(RMAKE) - $(CD) .. - $(ECHO) -- Done with $@ - -kcreddb: kmq - $(ECHO) -- Entering $@: - $(CD) $@ - $(RMAKE) - $(CD) .. - $(ECHO) -- Done with $@ - -kmm: kcreddb - $(ECHO) -- Entering $@: - $(CD) $@ - $(RMAKE) - $(CD) .. - $(ECHO) -- Done with $@ - -help: kmm - $(ECHO) -- Entering $@: - $(CD) $@ - $(RMAKE) - $(CD) .. - $(ECHO) -- Done with $@ - -uilib: help - $(ECHO) -- Entering $@: - $(CD) $@ - $(RMAKE) - $(RMAKE_W2K) - $(CD) .. - $(ECHO) -- Done with $@ - -nidmgrdll: uilib - $(ECHO) -- Entering $@ - $(CD) $@ - $(RMAKE) - $(RMAKE_W2K) - $(CD) .. - $(ECHO) -- Done with $@ - -ui: nidmgrdll - $(ECHO) -- Entering $@: - $(CD) $@ - $(RMAKE) - $(RMAKE_W2K) - $(CD) .. - $(ECHO) -- Done with $@ - -# Now build the plugins -plugincommon: ui - $(ECHO) -- Entering $@ - $(CD) plugins\common - $(RMAKE) - $(CD) ..\.. - $(ECHO) -- Done with $@ - -krb5plugin: plugincommon - $(ECHO) -- Entering $@ - $(CD) plugins\krb5 - $(RMAKE) - $(CD) ..\.. - $(ECHO) -- Done with $@ - -!ifndef NO_KRB4 -finale: krb4plugin - -krb4plugin: plugincommon - $(ECHO) -- Entering $@ - $(CD) plugins\krb4 - $(RMAKE) - $(CD) ..\.. - $(ECHO) -- Done with $@ -!endif - -!ifdef BUILD_AFS -finale: afsplugin - -afsplugin: plugincommon - $(ECHO) -- Entering $@ - $(CD) plugins\afs - $(RMAKE) - $(CD) ..\.. - $(ECHO) -- Done with $@ -!endif - -!ifdef NODOCBUILD -doctarget= -!else -doctarget=doc -!endif - -finale: krb5plugin $(doctarget) - $(ECHO) -- Done. - -pdoc: - -doc: pdoc - $(ECHO) -- Entering $@: - $(CD) $@ - $(RMAKE) - $(CD) .. - $(ECHO) -- Done with $@ - -clean:: - $(MAKECMD) /nologo CLEANRUN=1 - -test:: - $(MAKECMD) /nologo TESTRUN=1 - -etags:: - $(RM) $(TAGFILE) - $(MAKECMD) /nologo ETAGRUN=1 +# +# Copyright (c) 2004 Massachusetts Institute of Technology +# Copyright (c) 2006 Secure Endpoints Inc. +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +!ifdef ETAGRUN +all: finale doc +!else +all: finale +!endif + +MODULE=all +!include + +!ifndef CLEANRUN +!ifndef TESTRUN +!ifndef ETAGRUN + +# Define KH_NO_WX if the build should not fail on warnings. The +# default is to treat warnings as errors. + +#RMAKE=$(MAKECMD) /nologo all KH_NO_WX=1 +RMAKE=$(MAKECMD) /nologo all +RMAKE_W2K=$(MAKECMD) /nologo all KHBUILD_W2K=1 + +!else +RMAKE=$(MAKECMD) /nologo etag +RMAKE_W2K=echo Skipping W2K target for ETAGS run. +!endif +!else +RMAKE=$(MAKECMD) /nologo test +RMAKE_W2K=$(MAKECMD) /nologo test KHBUILD_W2K=1 +!endif +!else +RMAKE=$(MAKECMD) /nologo clean +RMAKE_W2K=$(MAKECMD) /nologo clean KHBUILD_W2K=1 +!endif + +!if "$(CPU)" != "i386" +NO_KRB4=1 +!endif + +start: + +config: start + $(ECHO) -- Entering $@: + $(CD) $@ + $(RMAKE) + $(CD) .. + $(ECHO) -- Done with $@ + +include: config + $(ECHO) -- Entering $@: + $(CD) $@ + $(RMAKE) + $(CD) .. + $(ECHO) -- Done with $@ + +util: include + $(ECHO) -- Entering $@: + $(CD) $@ + $(RMAKE) + $(CD) .. + $(ECHO) -- Done with $@ + +kherr: util + $(ECHO) -- Entering $@: + $(CD) $@ + $(RMAKE) + $(CD) .. + $(ECHO) -- Done with $@ + +kconfig: kherr + $(ECHO) -- Entering $@: + $(CD) $@ + $(RMAKE) + $(CD) .. + $(ECHO) -- Done with $@ + +kmq: kconfig + $(ECHO) -- Entering $@: + $(CD) $@ + $(RMAKE) + $(CD) .. + $(ECHO) -- Done with $@ + +kcreddb: kmq + $(ECHO) -- Entering $@: + $(CD) $@ + $(RMAKE) + $(CD) .. + $(ECHO) -- Done with $@ + +kmm: kcreddb + $(ECHO) -- Entering $@: + $(CD) $@ + $(RMAKE) + $(CD) .. + $(ECHO) -- Done with $@ + +help: kmm + $(ECHO) -- Entering $@: + $(CD) $@ + $(RMAKE) + $(CD) .. + $(ECHO) -- Done with $@ + +uilib: help + $(ECHO) -- Entering $@: + $(CD) $@ + $(RMAKE) + $(RMAKE_W2K) + $(CD) .. + $(ECHO) -- Done with $@ + +nidmgrdll: uilib + $(ECHO) -- Entering $@ + $(CD) $@ + $(RMAKE) + $(RMAKE_W2K) + $(CD) .. + $(ECHO) -- Done with $@ + +ui: nidmgrdll + $(ECHO) -- Entering $@: + $(CD) $@ + $(RMAKE) + $(RMAKE_W2K) + $(CD) .. + $(ECHO) -- Done with $@ + +# Now build the plugins +plugincommon: ui + $(ECHO) -- Entering $@ + $(CD) plugins\common + $(RMAKE) + $(CD) ..\.. + $(ECHO) -- Done with $@ + +krb5plugin: plugincommon + $(ECHO) -- Entering $@ + $(CD) plugins\krb5 + $(RMAKE) + $(CD) ..\.. + $(ECHO) -- Done with $@ + +!ifndef NO_KRB4 +finale: krb4plugin + +krb4plugin: plugincommon + $(ECHO) -- Entering $@ + $(CD) plugins\krb4 + $(RMAKE) + $(CD) ..\.. + $(ECHO) -- Done with $@ +!endif + +!ifdef BUILD_AFS +finale: afsplugin + +afsplugin: plugincommon + $(ECHO) -- Entering $@ + $(CD) plugins\afs + $(RMAKE) + $(CD) ..\.. + $(ECHO) -- Done with $@ +!endif + +!ifdef NODOCBUILD +doctarget= +!else +doctarget=doc +!endif + +finale: krb5plugin $(doctarget) + $(ECHO) -- Done. + +pdoc: + +doc: pdoc + $(ECHO) -- Entering $@: + $(CD) $@ + $(RMAKE) + $(CD) .. + $(ECHO) -- Done with $@ + +clean:: + $(MAKECMD) /nologo CLEANRUN=1 + +test:: + $(MAKECMD) /nologo TESTRUN=1 + +etags:: + $(RM) $(TAGFILE) + $(MAKECMD) /nologo ETAGRUN=1 diff --git a/src/windows/identity/kcreddb/credential.c b/src/windows/identity/kcreddb/credential.c index c8a423a2a..c241943d0 100644 --- a/src/windows/identity/kcreddb/credential.c +++ b/src/windows/identity/kcreddb/credential.c @@ -153,7 +153,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_update(khm_handle vdest, goto _skip_copy; } - kcdb_buf_set_value(&dest->buf, i, i, srcbuf, cbsrcbuf); + kcdb_buf_set_value(&dest->buf, i, (khm_ui_2) i, srcbuf, cbsrcbuf); rv = KHM_ERROR_SUCCESS; _skip_copy: @@ -166,7 +166,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_update(khm_handle vdest, if (!(a->flags & KCDB_ATTR_FLAG_COMPUTED) && (a->flags & KCDB_ATTR_FLAG_TRANSIENT) && kcdb_cred_val_exist(dest, i)) { - kcdb_buf_set_value(&dest->buf, i, i, NULL, 0); + kcdb_buf_set_value(&dest->buf, i, (khm_ui_2) i, NULL, 0); rv = KHM_ERROR_SUCCESS; } @@ -372,7 +372,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_set_attr( if (buffer == 0) { /* we are removing the value */ - kcdb_buf_alloc(&cred->buf, attr_id, attr_id, 0); + kcdb_buf_alloc(&cred->buf, attr_id, (khm_ui_2) attr_id, 0); code = KHM_ERROR_SUCCESS; goto _exit; } @@ -393,7 +393,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_set_attr( goto _exit; } - kcdb_buf_alloc(&cred->buf, attr_id, attr_id, cbdest); + kcdb_buf_alloc(&cred->buf, attr_id, (khm_ui_2) attr_id, cbdest); if(!kcdb_cred_buf_exist(cred, attr_id)) { code = KHM_ERROR_NO_RESOURCES; goto _exit; @@ -402,7 +402,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_set_attr( if(KHM_FAILED(code = type->dup(buffer, cbbuf, kcdb_cred_buf_get(cred,attr_id), &cbdest))) { - kcdb_buf_alloc(&cred->buf, attr_id, attr_id, 0); + kcdb_buf_alloc(&cred->buf, attr_id, (khm_ui_2) attr_id, 0); goto _exit; } diff --git a/src/windows/identity/kcreddb/credset.c b/src/windows/identity/kcreddb/credset.c index 41ca19a46..92f6c0519 100644 --- a/src/windows/identity/kcreddb/credset.c +++ b/src/windows/identity/kcreddb/credset.c @@ -1054,28 +1054,17 @@ kcdb_credset_unseal(khm_handle credset) { return rv; } +/* These are protected with cs_credset */ +static void * _creds_comp_rock = NULL; +static kcdb_cred_comp_func _creds_comp_func = NULL; -/* wrapper for qsort and also parameter gobbling FSM. Access to this - function is serialized via cs_credset. */ +/* Need cs_credset when calling this function. */ int __cdecl kcdb_creds_comp_wrapper(const void * a, const void * b) { - static void * rock = NULL; - static kcdb_cred_comp_func comp = NULL; - - if(!b) { - rock = (void *) a; - return 0; - } - - if(!a) { - comp = (kcdb_cred_comp_func) b; - return 0; - } - - return comp((khm_handle) ((kcdb_credset_credref *)a)->cred, - (khm_handle) ((kcdb_credset_credref *)b)->cred, - rock); + return (*_creds_comp_func)((khm_handle) ((kcdb_credset_credref *)a)->cred, + (khm_handle) ((kcdb_credset_credref *)b)->cred, + _creds_comp_rock); } KHMEXP khm_int32 KHMAPI @@ -1102,8 +1091,8 @@ kcdb_credset_sort(khm_handle credset, EnterCriticalSection(&cs_credset); - kcdb_creds_comp_wrapper(rock, NULL); - kcdb_creds_comp_wrapper(NULL, (void *) comp); + _creds_comp_rock = rock; + _creds_comp_func = comp; qsort(cs->clist, cs->nclist, sizeof(kcdb_credset_credref), kcdb_creds_comp_wrapper); diff --git a/src/windows/identity/kcreddb/identity.c b/src/windows/identity/kcreddb/identity.c index e14ceec4c..78cdedbf6 100644 --- a/src/windows/identity/kcreddb/identity.c +++ b/src/windows/identity/kcreddb/identity.c @@ -880,10 +880,10 @@ kcdb_identity_set_attr(khm_handle vid, if (buffer == NULL) { /* we are removing a value */ - slot = kcdb_buf_slot_by_id(&id->buf, attr_id); + slot = kcdb_buf_slot_by_id(&id->buf, (khm_ui_2) attr_id); if (slot != KCDB_BUF_INVALID_SLOT && kcdb_buf_exist(&id->buf, slot)) - kcdb_buf_alloc(&id->buf, slot, attr_id, 0); + kcdb_buf_alloc(&id->buf, slot, (khm_ui_2) attr_id, 0); code = KHM_ERROR_SUCCESS; goto _exit; } @@ -904,8 +904,8 @@ kcdb_identity_set_attr(khm_handle vid, goto _exit; } - kcdb_buf_alloc(&id->buf, KCDB_BUF_APPEND, attr_id, cbdest); - slot = kcdb_buf_slot_by_id(&id->buf, attr_id); + kcdb_buf_alloc(&id->buf, KCDB_BUF_APPEND, (khm_ui_2) attr_id, cbdest); + slot = kcdb_buf_slot_by_id(&id->buf, (khm_ui_2) attr_id); if(slot == KCDB_BUF_INVALID_SLOT || !kcdb_buf_exist(&id->buf, slot)) { code = KHM_ERROR_NO_RESOURCES; goto _exit; @@ -914,7 +914,7 @@ kcdb_identity_set_attr(khm_handle vid, if(KHM_FAILED(code = type->dup(buffer, cbbuf, kcdb_buf_get(&id->buf, slot), &cbdest))) { - kcdb_buf_alloc(&id->buf, slot, attr_id, 0); + kcdb_buf_alloc(&id->buf, slot, (khm_ui_2) attr_id, 0); goto _exit; } @@ -984,7 +984,7 @@ kcdb_identity_get_attr(khm_handle vid, id = (kcdb_identity *) vid; if(!(id->flags & KCDB_IDENT_FLAG_ATTRIBS) || - (slot = kcdb_buf_slot_by_id(&id->buf, attr_id)) == KCDB_BUF_INVALID_SLOT || + (slot = kcdb_buf_slot_by_id(&id->buf, (khm_ui_2) attr_id)) == KCDB_BUF_INVALID_SLOT || !kcdb_buf_val_exist(&id->buf, slot)) { code = KHM_ERROR_NOT_FOUND; @@ -1077,7 +1077,7 @@ kcdb_identity_get_attr_string(khm_handle vid, id = (kcdb_identity *) vid; if(!(id->flags & KCDB_IDENT_FLAG_ATTRIBS) || - (slot = kcdb_buf_slot_by_id(&id->buf, attr_id)) == KCDB_BUF_INVALID_SLOT || + (slot = kcdb_buf_slot_by_id(&id->buf, (khm_ui_2) attr_id)) == KCDB_BUF_INVALID_SLOT || !kcdb_buf_val_exist(&id->buf, slot)) { code = KHM_ERROR_NOT_FOUND; diff --git a/src/windows/identity/kcreddb/kcreddb.h b/src/windows/identity/kcreddb/kcreddb.h index 9d54105c4..6621d43cc 100644 --- a/src/windows/identity/kcreddb/kcreddb.h +++ b/src/windows/identity/kcreddb/kcreddb.h @@ -81,7 +81,7 @@ \note Not all functions that take a count of bytes support the \a KCDB_CBSIZE_AUTO value. */ -#define KCDB_CBSIZE_AUTO (-1) +#define KCDB_CBSIZE_AUTO ((khm_size) -1) /*! \defgroup kcdb_ident Identities diff --git a/src/windows/identity/kherr/kherr.c b/src/windows/identity/kherr/kherr.c index e4435e5fc..8c43fd811 100644 --- a/src/windows/identity/kherr/kherr.c +++ b/src/windows/identity/kherr/kherr.c @@ -314,23 +314,26 @@ free_event_params(kherr_event * e) if(parm_type(e->p1) == KEPT_STRINGT) { assert((void *) parm_data(e->p1)); PFREE((void*) parm_data(e->p1)); - ZeroMemory(&e->p1, sizeof(e->p1)); } + ZeroMemory(&e->p1, sizeof(e->p1)); + if(parm_type(e->p2) == KEPT_STRINGT) { assert((void *) parm_data(e->p2)); PFREE((void*) parm_data(e->p2)); - ZeroMemory(&e->p2, sizeof(e->p2)); } + ZeroMemory(&e->p2, sizeof(e->p2)); + if(parm_type(e->p3) == KEPT_STRINGT) { assert((void *) parm_data(e->p3)); PFREE((void*) parm_data(e->p3)); - ZeroMemory(&e->p3, sizeof(e->p3)); } + ZeroMemory(&e->p3, sizeof(e->p3)); + if(parm_type(e->p4) == KEPT_STRINGT) { assert((void *) parm_data(e->p4)); PFREE((void*) parm_data(e->p4)); - ZeroMemory(&e->p4, sizeof(e->p4)); } + ZeroMemory(&e->p4, sizeof(e->p4)); } static void @@ -339,15 +342,25 @@ free_event(kherr_event * e) EnterCriticalSection(&cs_error); assert(IS_KHERR_EVENT(e)); +#ifdef DEBUG + assert(LNEXT(e) == NULL); + assert(LPREV(e) == NULL); +#endif #ifdef DEBUG_CONTEXT - kherr_debug_printf(L"Freeing event 0x%x\n", e); if (!(e->flags & KHERR_RF_STR_RESOLVED)) resolve_event_strings(e); - if (e->short_desc) - kherr_debug_printf(L" Desc(S):[%s]\n", e->short_desc); - if (e->long_desc) - kherr_debug_printf(L" Desc(L):[%s]\n", e->long_desc); + + if (e->short_desc && e->long_desc) { + kherr_debug_printf(L"E:%s (%s)\n", e->short_desc, e->long_desc); + } else if (e->short_desc) { + kherr_debug_printf(L"E:%s\n", e->short_desc); + } else if (e->long_desc) { + kherr_debug_printf(L"E:%s\n", e->long_desc); + } else { + kherr_debug_printf(L"E:[No description for event 0x%p]\n", e); + } + if (e->suggestion) kherr_debug_printf(L" Suggest:[%s]\n", e->suggestion); if (e->facility) @@ -449,6 +462,9 @@ add_event(kherr_context * c, kherr_event * e) assert(IS_KHERR_CTX(c)); assert(IS_KHERR_EVENT(e)); +#ifdef DEBUG + assert(LPREV(e) == NULL && LNEXT(e) == NULL); +#endif EnterCriticalSection(&cs_error); te = QBOTTOM(c); @@ -502,46 +518,67 @@ pick_err_event(kherr_context * c) } static void -arg_from_param(DWORD_PTR ** parm, kherr_param p) +va_arg_from_param(va_list * parm, kherr_param p) { - int t; - - if (p.type != KEPT_NONE) { - t = parm_type(p); - if (t == KEPT_INT32 || - t == KEPT_UINT32 || - t == KEPT_STRINGC || - t == KEPT_STRINGT || - t == KEPT_PTR) { - - *(*parm)++ = (DWORD_PTR) parm_data(p); - - } else if (t == KEPT_INT64 || - t == KEPT_UINT64) { - *(*parm)++ = (DWORD_PTR) parm_data(p) & 0xffffffff; - *(*parm)++ = (DWORD_PTR) (parm_data(p) >> 32) & 0xffffffff; - } else - *(*parm)++ = 0; + int t = parm_type(p); + + khm_int32 * pi; + wchar_t ** ps; + void ** pptr; + khm_int64 * pli; + + if (t != KEPT_NONE) { + switch (t) { + case KEPT_INT32: + case KEPT_UINT32: + pi = (khm_int32 *)(*parm); + va_arg(*parm, khm_int32); + *pi = (khm_int32) parm_data(p); + break; + + case KEPT_STRINGC: + case KEPT_STRINGT: + ps = (wchar_t **) (*parm); + va_arg(*parm, wchar_t *); + *ps = (wchar_t *) parm_data(p); + break; + + case KEPT_PTR: + pptr = (void **) (*parm); + va_arg(*parm, void *); + *pptr = (void *) parm_data(p); + break; + + case KEPT_INT64: + case KEPT_UINT64: + pli = (khm_int64 *) (*parm); + va_arg(*parm, khm_int64); + *pli = (khm_int64) parm_data(p); + break; + +#ifdef DEBUG + default: + assert(FALSE); +#endif + } } } -/* The 'buf' parameter MUST point to a DWORD_PTR[8] array */ static void -args_from_event(DWORD_PTR * buf, kherr_event * e) +va_args_from_event(va_list args, kherr_event * e, khm_size cb) { - arg_from_param(&buf, e->p1); - arg_from_param(&buf, e->p2); - arg_from_param(&buf, e->p3); - arg_from_param(&buf, e->p4); -} + ZeroMemory(args, cb); -#ifdef _WIN64 -# error resolve_string_resource() does not work on 64 bit architectures -#endif + va_arg_from_param(&args, e->p1); + va_arg_from_param(&args, e->p2); + va_arg_from_param(&args, e->p3); + va_arg_from_param(&args, e->p4); +} static void resolve_string_resource(kherr_event * e, const wchar_t ** str, + va_list vl, khm_int32 if_flag, khm_int32 or_flag) { @@ -558,18 +595,9 @@ resolve_string_resource(kherr_event * e, *str = NULL; else { wchar_t * s; - DWORD_PTR args[8]; - - args_from_event(args, e); - chars = FormatMessage(FORMAT_MESSAGE_FROM_STRING | - FORMAT_MESSAGE_ARGUMENT_ARRAY, - tfmt, - 0, - 0, - tbuf, - ARRAYLENGTH(tbuf), - (va_list *) args); + chars = FormatMessage(FORMAT_MESSAGE_FROM_STRING, tfmt, + 0, 0, tbuf, ARRAYLENGTH(tbuf), &vl); if (chars == 0) { *str = NULL; @@ -586,33 +614,27 @@ resolve_string_resource(kherr_event * e, } } -#ifdef _WIN64 -# error resolve_msg_resource() does not work on 64 bit architectures -#endif - static void resolve_msg_resource(kherr_event * e, const wchar_t ** str, + va_list vl, khm_int32 if_flag, khm_int32 or_flag) { wchar_t tbuf[KHERR_MAXCCH_STRING]; size_t chars = 0; size_t bytes = 0; - DWORD_PTR args[8]; if(e->flags & if_flag) { if(e->h_module != NULL) { - args_from_event(args, e); - chars = FormatMessage(FORMAT_MESSAGE_FROM_HMODULE | - FORMAT_MESSAGE_ARGUMENT_ARRAY, + chars = FormatMessage(FORMAT_MESSAGE_FROM_HMODULE, (LPCVOID) e->h_module, (DWORD)(DWORD_PTR) *str, 0, tbuf, ARRAYLENGTH(tbuf), - (va_list *) args); + &vl); } if(e->h_module == NULL || chars == 0) { @@ -640,13 +662,10 @@ resolve_msg_resource(kherr_event * e, } } -#ifdef _WIN64 -# error resolve_string() does not work on 64 bit architectures -#endif - static void resolve_string(kherr_event * e, const wchar_t ** str, + va_list vl, khm_int32 mask, khm_int32 free_if, khm_int32 or_flag) @@ -654,21 +673,18 @@ resolve_string(kherr_event * e, wchar_t tbuf[KHERR_MAXCCH_STRING]; size_t chars; size_t bytes; - DWORD_PTR args[8]; if (((e->flags & mask) == 0 || - (e->flags & mask) == free_if) && + (e->flags & mask) == free_if) && *str != NULL) { - args_from_event(args, e); - chars = FormatMessage(FORMAT_MESSAGE_FROM_STRING | - FORMAT_MESSAGE_ARGUMENT_ARRAY, + chars = FormatMessage(FORMAT_MESSAGE_FROM_STRING, (LPCVOID) *str, 0, 0, tbuf, ARRAYLENGTH(tbuf), - (va_list *) args); + &vl); if ((e->flags & mask) == free_if) { PFREE((void *) *str); @@ -695,41 +711,46 @@ resolve_string(kherr_event * e, void resolve_event_strings(kherr_event * e) { - resolve_string(e, &e->short_desc, + DWORD_PTR args[8]; + va_list vl = (va_list) args; + + va_args_from_event(vl, e, sizeof(args)); + + resolve_string(e, &e->short_desc, vl, KHERR_RFMASK_SHORT_DESC, KHERR_RF_FREE_SHORT_DESC, KHERR_RF_FREE_SHORT_DESC); - resolve_string(e, &e->long_desc, + resolve_string(e, &e->long_desc, vl, KHERR_RFMASK_LONG_DESC, KHERR_RF_FREE_LONG_DESC, KHERR_RF_FREE_LONG_DESC); - resolve_string(e, &e->suggestion, + resolve_string(e, &e->suggestion, vl, KHERR_RFMASK_SUGGEST, KHERR_RF_FREE_SUGGEST, KHERR_RF_FREE_SUGGEST); - resolve_string_resource(e, &e->short_desc, + resolve_string_resource(e, &e->short_desc, vl, KHERR_RF_RES_SHORT_DESC, KHERR_RF_FREE_SHORT_DESC); - resolve_string_resource(e, &e->long_desc, - KHERR_RF_RES_LONG_DESC, + resolve_string_resource(e, &e->long_desc, vl, + KHERR_RF_RES_LONG_DESC, KHERR_RF_FREE_LONG_DESC); - resolve_string_resource(e, &e->suggestion, - KHERR_RF_RES_SUGGEST, + resolve_string_resource(e, &e->suggestion, vl, + KHERR_RF_RES_SUGGEST, KHERR_RF_FREE_SUGGEST); - resolve_msg_resource(e, &e->short_desc, - KHERR_RF_MSG_SHORT_DESC, + resolve_msg_resource(e, &e->short_desc, vl, + KHERR_RF_MSG_SHORT_DESC, KHERR_RF_FREE_SHORT_DESC); - resolve_msg_resource(e, &e->long_desc, - KHERR_RF_MSG_LONG_DESC, + resolve_msg_resource(e, &e->long_desc, vl, + KHERR_RF_MSG_LONG_DESC, KHERR_RF_FREE_LONG_DESC); - resolve_msg_resource(e, &e->suggestion, - KHERR_RF_MSG_SUGGEST, + resolve_msg_resource(e, &e->suggestion, vl, + KHERR_RF_MSG_SUGGEST, KHERR_RF_FREE_SUGGEST); /* get rid of dangling reference now that we have done everything diff --git a/src/windows/identity/kherr/kherr.h b/src/windows/identity/kherr/kherr.h index a74664d98..90a72a35a 100644 --- a/src/windows/identity/kherr/kherr.h +++ b/src/windows/identity/kherr/kherr.h @@ -635,7 +635,7 @@ kherr_reportf(const wchar_t * long_desc_fmt, then only the first part of the string that fits within the limit is duplicated. - The resulign ::kherr_param must be passed in to kherr_report(). + The resulting ::kherr_param must be passed in to kherr_report(). The event logging framework will free the duplicated string once the data is no longer required. */ diff --git a/src/windows/identity/kmm/kmm.c b/src/windows/identity/kmm/kmm.c index 721865c4d..e2784e8fd 100644 --- a/src/windows/identity/kmm/kmm.c +++ b/src/windows/identity/kmm/kmm.c @@ -61,7 +61,7 @@ khm_boolean kmmint_load_locale_lib(kmm_module_i * m, kmm_module_locale * l) EnterCriticalSection(&cs_kmm); m->h_resource = h; - m->lcid_resource = l->language; + m->lcid_resource = (WORD) l->language; LeaveCriticalSection(&cs_kmm); return TRUE; @@ -72,7 +72,7 @@ khm_boolean kmmint_load_locale_lib(kmm_module_i * m, kmm_module_locale * l) EnterCriticalSection(&cs_kmm); m->h_resource = m->h_module; - m->lcid_resource = l->language; + m->lcid_resource = (WORD) l->language; LeaveCriticalSection(&cs_kmm); return TRUE; diff --git a/src/windows/identity/kmm/kmm_module.c b/src/windows/identity/kmm/kmm_module.c index 52c34ac03..13fae87d3 100644 --- a/src/windows/identity/kmm/kmm_module.c +++ b/src/windows/identity/kmm/kmm_module.c @@ -166,6 +166,7 @@ kmmint_read_module_info(kmm_module_i * m) { wchar_t resname[256]; /* the resource names are a lot shorter */ wchar_t * r; VS_FIXEDFILEINFO *vff; + UINT c; assert(m->name); assert(m->path); @@ -203,14 +204,14 @@ kmmint_read_module_info(kmm_module_i * m) { if(!VerQueryValue(m->version_info, L"\\VarFileInfo\\Translation", (LPVOID*) &languages, - &cb)) { + &c)) { rv = KHM_ERROR_INVALID_PARAM; _report_mr1(KHERR_WARNING, MSG_RMI_NO_TRANS, _dupstr(m->path)); _location(L"VerQueryValue"); goto _cleanup; } - n_languages = (int) (cb / sizeof(*languages)); + n_languages = (int) (c / sizeof(*languages)); /* Try searching for the user's default language first */ lang = GetUserDefaultLangID(); @@ -261,14 +262,14 @@ kmmint_read_module_info(kmm_module_i * m) { languages[i].codepage); if (!VerQueryValue(m->version_info, - resname, (LPVOID *) &r, &cb)) { + resname, (LPVOID *) &r, &c)) { rv = KHM_ERROR_INVALID_PARAM; _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, _cstr(TEXT(NIMV_MODULE))); goto _cleanup; } - if (cb > KMM_MAXCB_NAME || + if (c > KMM_MAXCB_NAME || FAILED(StringCbLength(r, KMM_MAXCB_NAME, &cb))) { rv = KHM_ERROR_INVALID_PARAM; _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG, @@ -290,14 +291,14 @@ kmmint_read_module_info(kmm_module_i * m) { languages[i].codepage); if (!VerQueryValue(m->version_info, - resname, (LPVOID *) &r, &cb)) { + resname, (LPVOID *) &r, &c)) { rv = KHM_ERROR_INVALID_PARAM; _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, _cstr(TEXT(NIMV_APIVER))); goto _cleanup; } - if (cb > KMM_MAXCB_NAME || + if (c > KMM_MAXCB_NAME || FAILED(StringCbLength(r, KMM_MAXCB_NAME, &cb))) { rv = KHM_ERROR_INVALID_PARAM; _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG, @@ -328,14 +329,14 @@ kmmint_read_module_info(kmm_module_i * m) { languages[i].codepage); if (!VerQueryValue(m->version_info, - resname, (LPVOID *) &r, &cb)) { + resname, (LPVOID *) &r, &c)) { rv = KHM_ERROR_INVALID_PARAM; _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, _cstr(L"FileDescription")); goto _cleanup; } - if (cb > KMM_MAXCB_DESC || + if (c > KMM_MAXCB_DESC || FAILED(StringCbLength(r, KMM_MAXCB_DESC, &cb))) { rv = KHM_ERROR_INVALID_PARAM; _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG, @@ -363,14 +364,14 @@ kmmint_read_module_info(kmm_module_i * m) { languages[i].codepage); if (!VerQueryValue(m->version_info, - resname, (LPVOID *) &r, &cb)) { + resname, (LPVOID *) &r, &c)) { rv = KHM_ERROR_INVALID_PARAM; _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, _cstr(TEXT(NIMV_SUPPORT))); goto _cleanup; } - if (cb > KMM_MAXCB_SUPPORT || + if (c > KMM_MAXCB_SUPPORT || FAILED(StringCbLength(r, KMM_MAXCB_SUPPORT, &cb))) { rv = KHM_ERROR_INVALID_PARAM; _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG, @@ -398,14 +399,14 @@ kmmint_read_module_info(kmm_module_i * m) { languages[i].codepage); if (!VerQueryValue(m->version_info, - resname, (LPVOID *) &r, &cb)) { + resname, (LPVOID *) &r, &c)) { rv = KHM_ERROR_INVALID_PARAM; _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, _cstr(L"LegalCopyright")); goto _cleanup; } - if (cb > KMM_MAXCB_SUPPORT || + if (c > KMM_MAXCB_SUPPORT || FAILED(StringCbLength(r, KMM_MAXCB_SUPPORT, &cb))) { rv = KHM_ERROR_INVALID_PARAM; _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG, @@ -423,9 +424,8 @@ kmmint_read_module_info(kmm_module_i * m) { if (!VerQueryValue(m->version_info, L"\\", - (LPVOID *) &vff, - &cb) || - cb != sizeof(*vff)) { + (LPVOID *) &vff, &c) || + c != sizeof(*vff)) { rv = KHM_ERROR_INVALID_PARAM; _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, diff --git a/src/windows/identity/kmm/kmm_reg.c b/src/windows/identity/kmm/kmm_reg.c index 66354229f..564e662c6 100644 --- a/src/windows/identity/kmm/kmm_reg.c +++ b/src/windows/identity/kmm/kmm_reg.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology - * Copyright (c) 2006 Secure Endpoints Inc. + * Copyright (c) 2006, 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation diff --git a/src/windows/identity/kmm/kmm_registrar.c b/src/windows/identity/kmm/kmm_registrar.c index 0aa4b425f..259f868b9 100644 --- a/src/windows/identity/kmm/kmm_registrar.c +++ b/src/windows/identity/kmm/kmm_registrar.c @@ -147,8 +147,6 @@ DWORD WINAPI kmmint_registrar(LPVOID lpParameter) kmq_unsubscribe(KMSG_SYSTEM, kmmint_reg_cb); ExitThread(0); - /* not reached */ - return 0; } /*! \internal @@ -174,14 +172,9 @@ DWORD WINAPI kmmint_plugin_broker(LPVOID lpParameter) p->tid_thread = GetCurrentThreadId(); - if (IsBadCodePtr(p->p.msg_proc)) { - _report_mr0(KHERR_WARNING, MSG_PB_INVALID_CODE_PTR); - rv = KHM_ERROR_INVALID_PARAM; - } else { - rv = (*p->p.msg_proc)(KMSG_SYSTEM, KMSG_SYSTEM_INIT, - 0, (void *) &(p->p)); - _report_mr1(KHERR_INFO, MSG_PB_INIT_RV, _int32(rv)); - } + rv = (*p->p.msg_proc)(KMSG_SYSTEM, KMSG_SYSTEM_INIT, + 0, (void *) &(p->p)); + _report_mr1(KHERR_INFO, MSG_PB_INIT_RV, _int32(rv)); /* if it fails to initialize, we exit the plugin */ if(KHM_FAILED(rv)) { @@ -294,9 +287,6 @@ DWORD WINAPI kmmint_plugin_broker(LPVOID lpParameter) TlsSetValue(tls_kmm, (LPVOID) 0); ExitThread(rv); - - /* not reached */ - return rv; } /*! \internal @@ -684,12 +674,12 @@ void kmmint_init_module(kmm_module_i * m) { } } - if(khc_read_string(csp_mod, L"ImagePath", NULL, &sz) == + if(khc_read_string(csp_mod, KMM_VALNAME_IMAGEPATH, NULL, &sz) == KHM_ERROR_TOO_LONG) { if(m->path) PFREE(m->path); m->path = PMALLOC(sz); - khc_read_string(csp_mod, L"ImagePath", m->path, &sz); + khc_read_string(csp_mod, KMM_VALNAME_IMAGEPATH, m->path, &sz); } else { _report_mr0(KHERR_ERROR, MSG_IM_NOT_REGISTERED); diff --git a/src/windows/identity/kmm/kmminternal.h b/src/windows/identity/kmm/kmminternal.h index b945d3509..96f8ac24a 100644 --- a/src/windows/identity/kmm/kmminternal.h +++ b/src/windows/identity/kmm/kmminternal.h @@ -244,6 +244,7 @@ kmmint_load_locale_lib(kmm_module_i * m, kmm_module_locale * l); #define KMM_CSNAME_PLUGINS L"Plugins" #define KMM_CSNAME_MODULES L"Modules" #define KMM_VALNAME_LOADLIST L"LoadList" +#define KMM_VALNAME_IMAGEPATH L"ImagePath" void kmmint_add_to_module_queue(void); diff --git a/src/windows/identity/kmq/consumer.c b/src/windows/identity/kmq/consumer.c index 32bafec6e..2837d304c 100644 --- a/src/windows/identity/kmq/consumer.c +++ b/src/windows/identity/kmq/consumer.c @@ -84,7 +84,7 @@ kmqint_dump_consumer(FILE * f) { s, s->type, (s->rcpt_type == KMQ_RCPTTYPE_CB)?"CALLBACK":"HWND", - (s->rcpt_type == KMQ_RCPTTYPE_CB) ? (void *) s->recipient.cb: (void *) s->recipient.hwnd, + (s->rcpt_type == KMQ_RCPTTYPE_CB)? s->recipient.cb: (void *) s->recipient.hwnd, s->queue); s = LNEXT(s); @@ -216,12 +216,8 @@ void kmqint_post(kmq_msg_subscription * s, kmq_message * m, khm_boolean try_send the message queue. */ m->refcount++; m->nSent++; - if (IsBadCodePtr(s->recipient.cb)) { - rv = KHM_ERROR_INVALID_OPERATION; - } else { - rv = s->recipient.cb(m->type, m->subtype, - m->uparam, m->vparam); - } + rv = s->recipient.cb(m->type, m->subtype, + m->uparam, m->vparam); m->refcount--; if(KHM_SUCCEEDED(rv)) m->nCompleted++; diff --git a/src/windows/identity/kmq/init.c b/src/windows/identity/kmq/init.c index 493780f79..1c2023fc8 100644 --- a/src/windows/identity/kmq/init.c +++ b/src/windows/identity/kmq/init.c @@ -220,9 +220,6 @@ DWORD WINAPI kmqint_completion_thread_proc(LPVOID p) { LeaveCriticalSection(&cs_compl); ExitThread(0); - - /* not reached */ - return 0; } int kmqint_call_completion_handler(kmq_msg_completion_handler h, diff --git a/src/windows/identity/plugins/common/dynimport.c b/src/windows/identity/plugins/common/dynimport.c index 24fa1a551..ea8bbf905 100644 --- a/src/windows/identity/plugins/common/dynimport.c +++ b/src/windows/identity/plugins/common/dynimport.c @@ -395,8 +395,10 @@ khm_int32 init_imports(void) { imp_rv = LoadFuncs(SECUR32_DLL, lsa_fi, &hSecur32, 0, 1, 1, 1); CKRV(SECUR32_DLL); +#ifndef _WIN64 imp_rv = LoadFuncs(KRB524_DLL, k524_fi, &hKrb524, 0, 1, 1, 1); CKRV(KRB524_DLL); +#endif imp_rv = LoadFuncs(PROFILE_DLL, profile_fi, &hProfile, 0, 1, 0, 0); CKRV(PROFILE_DLL); @@ -471,7 +473,7 @@ void Leash_load_com_err_callback(FARPROC ce, FARPROC em, FARPROC etn) { - (FARPROC)Lcom_err=ce; - (FARPROC)Lerror_message=em; - (FARPROC)Lerror_table_name=etn; + Lcom_err = (int (*)(LPSTR,long,LPSTR,...)) ce; + Lerror_message = (LPSTR (*)(long)) em; + Lerror_table_name = (LPSTR (*)(long)) etn; } diff --git a/src/windows/identity/plugins/common/dynimport.h b/src/windows/identity/plugins/common/dynimport.h index 850d96e5f..2c0995cba 100644 --- a/src/windows/identity/plugins/common/dynimport.h +++ b/src/windows/identity/plugins/common/dynimport.h @@ -49,11 +49,15 @@ extern HINSTANCE hProfile; /////////////////////////////////////////////////////////////////////////////// +#ifdef _WIN64 +#define CCAPI_DLL "krbcc64.dll" +#define KRBCC32_DLL "krbcc64.dll" +#else #define CCAPI_DLL "krbcc32.dll" #define KRBCC32_DLL "krbcc32.dll" +#endif #define SERVICE_DLL "advapi32.dll" #define SECUR32_DLL "secur32.dll" -#define PROFILE_DLL "xpprof32.dll" ////////////////////////////////////////////////////////////////////////////// diff --git a/src/windows/identity/plugins/krb4/krb4configdlg.c b/src/windows/identity/plugins/krb4/krb4configdlg.c index 309bf542b..c2ab3f562 100644 --- a/src/windows/identity/plugins/krb4/krb4configdlg.c +++ b/src/windows/identity/plugins/krb4/krb4configdlg.c @@ -393,8 +393,8 @@ krb4_confg_proc(HWND hwnd, CHAR krbrealm_path[MAX_PATH]; CHAR ticketName[MAX_PATH]; char * pticketName; - unsigned int krb_path_sz = sizeof(krb_path); - unsigned int krbrealm_path_sz = sizeof(krbrealm_path); + size_t krb_path_sz = sizeof(krb_path); + size_t krbrealm_path_sz = sizeof(krbrealm_path); khm_size cbsize; d = PMALLOC(sizeof(*d)); diff --git a/src/windows/identity/plugins/krb4/krb4funcs.c b/src/windows/identity/plugins/krb4/krb4funcs.c index 9e9ba42d2..e5287ca9f 100644 --- a/src/windows/identity/plugins/krb4/krb4funcs.c +++ b/src/windows/identity/plugins/krb4/krb4funcs.c @@ -297,7 +297,7 @@ khm_get_krb4_con_file(LPSTR confname, UINT szConfname) StringCchCopyA(confname, szConfname, krbConFile); } else if (hKrb4) { - unsigned int size = szConfname; + size_t size = szConfname; memset(confname, '\0', szConfname); if (!pkrb_get_krbconf2(confname, &size)) { GetWindowsDirectoryA(confname,szConfname); @@ -319,10 +319,10 @@ readstring(FILE * file, char * buf, int len) { if (i < sizeof(buf)) { if (c == '\n') { - buf[i] = '\0'; - return i; + buf[i] = '\0'; + return i; } else { - buf[i] = c; + buf[i] = (char)c; } } else { if (c == '\n') { diff --git a/src/windows/identity/plugins/krb5/krb5configdlg.c b/src/windows/identity/plugins/krb5/krb5configdlg.c index 36936cdea..ed11f7ec8 100644 --- a/src/windows/identity/plugins/krb5/krb5configdlg.c +++ b/src/windows/identity/plugins/krb5/krb5configdlg.c @@ -33,6 +33,8 @@ #include +#pragma warning(disable: 4204 4221) + typedef struct tag_k5_realm_kdc { wchar_t name[K5_MAXCCH_HOST]; khm_boolean admin; /* admin server? */ @@ -1034,7 +1036,7 @@ k5_config_dlgproc(HWND hwnd, (LPARAM) d->realms[i].realm); } - SendMessage(hw, CB_SELECTSTRING, -1, + SendMessage(hw, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) d->def_realm); SetDlgItemText(hwnd, IDC_CFG_DEFREALM, d->def_realm); SendDlgItemMessage(hwnd, IDC_CFG_DEFREALM, CB_LIMITTEXT, @@ -1082,7 +1084,7 @@ k5_config_dlgproc(HWND hwnd, SendMessage(hw, CB_SETCURSEL, 0, d->lsa_import); t = importopts; SendMessage(hw, CB_GETLBTEXT, d->lsa_import,(LPARAM) t); - SendMessage(hw, CB_SELECTSTRING, -1, (LPARAM) t); + SendMessage(hw, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) t); } break; diff --git a/src/windows/identity/plugins/krb5/krb5configid.c b/src/windows/identity/plugins/krb5/krb5configid.c index e730a4bb0..a2688e1e7 100644 --- a/src/windows/identity/plugins/krb5/krb5configid.c +++ b/src/windows/identity/plugins/krb5/krb5configid.c @@ -130,13 +130,11 @@ k5_id_read_params(k5_id_dlg_data * d) { d->public_ip = 0; cb = sizeof(d->ccache); - rv = khc_read_string(csp_ident, L"DefaultCCName", d->ccache, &cb); - if (KHM_FAILED(rv) || cb <= sizeof(wchar_t)) { - cb = sizeof(d->ccache); - if (KHM_FAILED(kcdb_identity_get_attr(d->ident, attr_id_krb5_ccname, - NULL, d->ccache, &cb))) - ZeroMemory(d->ccache, sizeof(d->ccache)); - } + rv = khm_krb5_get_identity_default_ccache(d->ident, d->ccache, &cb); + +#ifdef DEBUG + assert(KHM_SUCCEEDED(rv)); +#endif khui_tracker_initialize(&d->tc_life); d->tc_life.current = d->life; @@ -200,6 +198,7 @@ k5_id_write_params(HWND hw, k5_id_dlg_data * d) { khm_size cb; khm_int32 rv; khm_boolean b; + khm_boolean applied = FALSE; DWORD dwaddress = 0; if (!k5_id_is_mod(hw, d)) @@ -208,7 +207,7 @@ k5_id_write_params(HWND hw, k5_id_dlg_data * d) { rv = kcdb_identity_get_config(d->ident, KHM_FLAG_CREATE, &csp_idroot); if (KHM_SUCCEEDED(rv)) { khc_open_space(csp_idroot, CSNAME_KRB5CRED, - KHM_FLAG_CREATE, + KHM_FLAG_CREATE | KCONF_FLAG_WRITEIFMOD, &csp_ident); } @@ -221,29 +220,34 @@ k5_id_write_params(HWND hw, k5_id_dlg_data * d) { if (d->life != d->tc_life.current) { d->life = d->tc_life.current; khc_write_int32(csp_ident, L"DefaultLifetime", (khm_int32) d->life); + applied = TRUE; } if (d->renew_life != d->tc_renew.current) { d->renew_life = d->tc_renew.current; khc_write_int32(csp_ident, L"DefaultRenewLifetime", (khm_int32) d->renew_life); + applied = TRUE; } b = (IsDlgButtonChecked(hw, IDC_CFG_RENEW) == BST_CHECKED); if (b != d->renewable) { d->renewable = b; khc_write_int32(csp_ident, L"Renewable", (khm_int32) b); + applied = TRUE; } b = (IsDlgButtonChecked(hw, IDC_CFG_FORWARD) == BST_CHECKED); if (b != d->forwardable) { d->forwardable = b; khc_write_int32(csp_ident, L"Forwardable", (khm_int32) b); + applied = TRUE; } b = (IsDlgButtonChecked(hw, IDC_CFG_ADDRESSLESS) == BST_CHECKED); if (b != d->addressless) { d->addressless = b; khc_write_int32(csp_ident, L"Addressless", (khm_int32) b); + applied = TRUE; } SendDlgItemMessage(hw, IDC_CFG_PUBLICIP, IPM_GETADDRESS, @@ -252,23 +256,31 @@ k5_id_write_params(HWND hw, k5_id_dlg_data * d) { if (dwaddress != d->public_ip) { d->public_ip = dwaddress; khc_write_int32(csp_ident, L"PublicIP", (khm_int32) dwaddress); + applied = TRUE; } GetDlgItemText(hw, IDC_CFG_CCACHE, ccache, ARRAYLENGTH(ccache)); if (SUCCEEDED(StringCbLength(ccache, sizeof(ccache), &cb)) && - _wcsicmp(ccache, d->ccache)) { - khc_write_string(csp_ident, L"DefaultCCName", ccache); - StringCbCopy(d->ccache, sizeof(d->ccache), ccache); + cb > sizeof(wchar_t)) { + + if (wcscmp(ccache, d->ccache)) { + khc_write_string(csp_ident, L"DefaultCCName", ccache); + StringCbCopy(d->ccache, sizeof(d->ccache), ccache); + applied = TRUE; + } + } else { khc_remove_value(csp_ident, L"DefaultCCName", KCONF_FLAG_USER); + d->ccache[0] = L'\0'; + applied = TRUE; } if (csp_ident) khc_close_space(csp_ident); khui_cfg_set_flags_inst(&d->cfg, - KHUI_CNFLAG_APPLIED, + (applied ? KHUI_CNFLAG_APPLIED : 0), KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED); } diff --git a/src/windows/identity/plugins/krb5/krb5funcs.c b/src/windows/identity/plugins/krb5/krb5funcs.c index 6f657e851..4dc854845 100644 --- a/src/windows/identity/plugins/krb5/krb5funcs.c +++ b/src/windows/identity/plugins/krb5/krb5funcs.c @@ -1392,10 +1392,7 @@ khm_krb5_kinit(krb5_context alt_ctx, code = pkrb5_cc_resolve(ctx, ccache, &cc); } else { khm_handle identity = NULL; - khm_handle csp_ident = NULL; - khm_handle csp_k5 = NULL; wchar_t idname[KCDB_IDENT_MAXCCH_NAME]; - wchar_t wccname[MAX_PATH]; char ccname[MAX_PATH]; char * pccname = principal_name; khm_size cb; @@ -1403,30 +1400,15 @@ khm_krb5_kinit(krb5_context alt_ctx, idname[0] = L'\0'; AnsiStrToUnicode(idname, sizeof(idname), principal_name); - cb = sizeof(wccname); + cb = sizeof(ccname); if (KHM_SUCCEEDED(kcdb_identity_create(idname, 0, &identity)) && + KHM_SUCCEEDED(khm_krb5_get_identity_default_ccacheA(identity, ccname, &cb))) { - KHM_SUCCEEDED(kcdb_identity_get_config(identity, 0, &csp_ident)) && - - KHM_SUCCEEDED(khc_open_space(csp_ident, CSNAME_KRB5CRED, 0, - &csp_k5)) && - - KHM_SUCCEEDED(khc_read_string(csp_k5, L"DefaultCCName", - wccname, &cb)) && - - cb > sizeof(wchar_t)) { - - _reportf(L"Using DefaultCCName [%s] from identity", wccname); - - UnicodeStrToAnsi(ccname, sizeof(ccname), wccname); pccname = ccname; + } - if (csp_k5) - khc_close_space(csp_k5); - if (csp_ident) - khc_close_space(csp_ident); if (identity) kcdb_identity_release(identity); @@ -2182,8 +2164,8 @@ khm_krb5_ms2mit(char * match_princ, BOOL match_realm, BOOL save_creds, krb5_cc_cursor cursor=0; krb5_principal princ = 0; khm_handle ident = NULL; - wchar_t wname[KCDB_IDENT_MAXCCH_NAME]; - char cname[KCDB_IDENT_MAXCCH_NAME]; + wchar_t idname[KCDB_IDENT_MAXCCH_NAME]; + char ccname[MAX_PATH]; char *cache_name = NULL; char *princ_name = NULL; BOOL rc = FALSE; @@ -2210,9 +2192,9 @@ khm_krb5_ms2mit(char * match_princ, BOOL match_realm, BOOL save_creds, if (code = pkrb5_unparse_name(kcontext, princ, &princ_name)) goto cleanup; - AnsiStrToUnicode(wname, sizeof(wname), princ_name); + AnsiStrToUnicode(idname, sizeof(idname), princ_name); - kherr_reportf(L"Unparsed name [%s]", wname); + kherr_reportf(L"Unparsed name [%s]", idname); /* see if we have to match a specific principal */ if (match_princ != NULL) { @@ -2245,48 +2227,26 @@ khm_krb5_ms2mit(char * match_princ, BOOL match_realm, BOOL save_creds, PFREE(wdefrealm); } - if (KHM_SUCCEEDED(kcdb_identity_create(wname, + if (KHM_SUCCEEDED(kcdb_identity_create(idname, KCDB_IDENT_FLAG_CREATE, &ident))) { - khm_handle idconfig = NULL; - khm_handle k5config = NULL; khm_size cb; - wname[0] = L'\0'; - - kcdb_identity_get_config(ident, KHM_FLAG_CREATE, &idconfig); - if (idconfig == NULL) - goto _done_checking_config; + cb = sizeof(ccname); - khc_open_space(idconfig, CSNAME_KRB5CRED, KHM_FLAG_CREATE, &k5config); - if (k5config == NULL) - goto _done_checking_config; + khm_krb5_get_identity_default_ccacheA(ident, ccname, &cb); - cb = sizeof(wname); - khc_read_string(k5config, - L"DefaultCCName", - wname, &cb); - - _done_checking_config: - - if (idconfig) - khc_close_space(idconfig); - if (k5config) - khc_close_space(k5config); - - if (wname[0]) { - UnicodeStrToAnsi(cname, sizeof(cname), wname); - } else { - StringCbPrintfA(cname, sizeof(cname), "API:%s", princ_name); - } - - cache_name = cname; + cache_name = ccname; } else { /* the identity could not be created. we just use the name of the principal as the ccache name. */ - StringCbPrintfA(cname, sizeof(cname), "API:%s", princ_name); - cache_name = cname; +#ifdef DEBUG + assert(FALSE); +#endif + kherr_reportf(L"Failed to create identity"); + StringCbPrintfA(ccname, sizeof(ccname), "API:%s", princ_name); + cache_name = ccname; } kherr_reportf(L"Resolving target cache [%S]\n", cache_name); @@ -2453,7 +2413,7 @@ khm_get_krb4_con_file(LPSTR confname, UINT szConfname) StringCchCopyA(confname, szConfname, krbConFile); } else if (hKrb4) { - unsigned int size = szConfname; + size_t size = szConfname; memset(confname, '\0', szConfname); if (!pkrb_get_krbconf2(confname, &size)) { // Error has happened @@ -2477,7 +2437,7 @@ readstring(FILE * file, char * buf, int len) buf[i] = '\0'; return i; } else { - buf[i] = c; + buf[i] = (char) c; } } else { if (c == '\n') { @@ -2579,7 +2539,7 @@ khm_krb5_get_realm_list(void) wchar_t * d; if (!khm_get_krb4_con_file(krb_conf,sizeof(krb_conf)) && -#if _MSC_VER >= 1400 +#if _MSC_VER >= 1400 && __STDC_WANT_SECURE_LIB__ !fopen_s(&file, krb_conf, "rt") #else (file = fopen(krb_conf, "rt")) @@ -3097,6 +3057,79 @@ get_libdefault_string(profile_t profile, const char * realm, return code; } +khm_int32 +khm_krb5_get_identity_default_ccache(khm_handle ident, wchar_t * buf, khm_size * pcb) { + khm_handle csp_id = NULL; + khm_int32 rv = KHM_ERROR_SUCCESS; + + rv = khm_krb5_get_identity_config(ident, 0, &csp_id); + + if (KHM_SUCCEEDED(rv)) + rv = khc_read_string(csp_id, L"DefaultCCName", buf, pcb); + + if (KHM_FAILED(rv) && rv != KHM_ERROR_TOO_LONG) { + /* we need to figure out the default ccache from the principal + name */ + wchar_t idname[KCDB_IDENT_MAXCCH_NAME]; + wchar_t ccname[MAX_PATH]; + khm_size cb; + + cb = sizeof(idname); + kcdb_identity_get_name(ident, idname, &cb); + StringCbCopy(ccname, sizeof(ccname), idname); + khm_krb5_canon_cc_name(ccname, sizeof(ccname)); + StringCbLength(ccname, sizeof(ccname), &cb); + + _reportf(L"Setting CCache [%s] for identity [%s]", ccname, idname); + + if (buf && *pcb >= cb) { + StringCbCopy(buf, *pcb, ccname); + *pcb = cb; + rv = KHM_ERROR_SUCCESS; + } else { + *pcb = cb; + rv = KHM_ERROR_TOO_LONG; + } + } else if (KHM_SUCCEEDED(rv)) { + wchar_t idname[KCDB_IDENT_MAXCCH_NAME]; + khm_size cb; + + cb = sizeof(idname); + kcdb_identity_get_name(ident, idname, &cb); + + _reportf(L"Found CCache [%s] for identity [%s]", buf, idname); + } + + if (csp_id != NULL) + khc_close_space(csp_id); + + return rv; +} + +khm_int32 +khm_krb5_get_identity_default_ccacheA(khm_handle ident, char * buf, khm_size * pcb) { + wchar_t wccname[MAX_PATH]; + khm_size cbcc; + khm_int32 rv; + + cbcc = sizeof(wccname); + rv = khm_krb5_get_identity_default_ccache(ident, wccname, &cbcc); + + if (KHM_SUCCEEDED(rv)) { + cbcc = sizeof(char) * cbcc / sizeof(wchar_t); + if (buf == NULL || *pcb < cbcc) { + *pcb = cbcc; + rv = KHM_ERROR_TOO_LONG; + } else { + UnicodeStrToAnsi(buf, *pcb, wccname); + *pcb = cbcc; + rv = KHM_ERROR_SUCCESS; + } + } + + return rv; +} + khm_int32 khm_krb5_get_identity_params(khm_handle ident, k5_params * p) { diff --git a/src/windows/identity/plugins/krb5/krb5funcs.h b/src/windows/identity/plugins/krb5/krb5funcs.h index d2ec28b47..990db269d 100644 --- a/src/windows/identity/plugins/krb5/krb5funcs.h +++ b/src/windows/identity/plugins/krb5/krb5funcs.h @@ -198,6 +198,12 @@ khm_krb5_set_identity_params(khm_handle ident, const k5_params * p); khm_int32 khm_krb5_get_identity_params(khm_handle ident, k5_params * p); +khm_int32 +khm_krb5_get_identity_default_ccache(khm_handle ident, wchar_t * buf, khm_size * pcb); + +khm_int32 +khm_krb5_get_identity_default_ccacheA(khm_handle ident, char * buf, khm_size * pcb); + /* Utility */ wchar_t * diff --git a/src/windows/identity/plugins/krb5/krb5identpro.c b/src/windows/identity/plugins/krb5/krb5identpro.c index c1c8f7be7..6f7ee3082 100644 --- a/src/windows/identity/plugins/krb5/krb5identpro.c +++ b/src/windows/identity/plugins/krb5/krb5identpro.c @@ -60,7 +60,7 @@ trim_str(wchar_t * s, khm_size cch) { return; if (c != s && ((khm_size)(c - s)) < cch) { -#if _MSC_VER >= 1400 +#if _MSC_VER >= 1400 && __STDC_WANT_SECURE_LIB__ wmemmove_s(s, cch, c, cch - ((khm_size)(c - s))); #else memmove(s, c, (cch - ((khm_size)(c - s))) * sizeof(wchar_t)); @@ -1770,9 +1770,6 @@ DWORD WINAPI k5_ccname_monitor_thread(LPVOID lpParameter) { _exit: ExitThread(rv); - - /* not reached */ - return rv; } khm_int32 diff --git a/src/windows/identity/plugins/krb5/krb5newcreds.c b/src/windows/identity/plugins/krb5/krb5newcreds.c index b382096a0..67fb8dac0 100644 --- a/src/windows/identity/plugins/krb5/krb5newcreds.c +++ b/src/windows/identity/plugins/krb5/krb5newcreds.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006 Secure Endpoints Inc. + * Copyright (c) 2006, 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -657,6 +657,7 @@ k5_kinit_fiber_proc(PVOID lpParameter) _reportf(L" g_fjob.state = %d", g_fjob.state); _reportf(L" g_fjob.prompt_set= %d", g_fjob.prompt_set); _reportf(L" g_fjob.valid_principal = %d", (int) g_fjob.valid_principal); + _reportf(L" g_fjob.ccache = [%s]", g_fjob.ccache); #endif /* If we don't know if we have a valid principal, we @@ -1355,7 +1356,7 @@ k5_read_dlg_params(k5_dlg_data * d, khm_handle identity) } void -k5_write_dlg_params(k5_dlg_data * d, khm_handle identity) +k5_write_dlg_params(k5_dlg_data * d, khm_handle identity, char * ccache) { k5_params p; @@ -1382,6 +1383,86 @@ k5_write_dlg_params(k5_dlg_data * d, khm_handle identity) khm_krb5_set_identity_params(identity, &p); + /* if we used a FILE: ccache, we should add it to FileCCList. + Otherwise the tickets are not going to get listed. */ + do { + wchar_t thisccache[MAX_PATH]; + wchar_t * ccpath; + khm_size cb_cc; + wchar_t * mlist = NULL; + khm_size cb_mlist; + khm_int32 rv; + khm_size t; + + if (ccache != NULL && + strncmp(ccache, "FILE:", 5) != 0) + break; + + if (ccache == NULL) { + cb_cc = sizeof(thisccache); + rv = khm_krb5_get_identity_default_ccache(identity, thisccache, &cb_cc); +#ifdef DEBUG + assert(KHM_SUCCEEDED(rv)); +#endif + } else { + thisccache[0] = L'\0'; + AnsiStrToUnicode(thisccache, sizeof(thisccache), ccache); + } + + if (wcsncmp(thisccache, L"FILE:", 5)) + break; + + /* the FileCCList is a list of paths. We have to strip out + the FILE: prefix. */ + ccpath = thisccache + 5; + + _reportf(L"Checking if ccache [%s] is in FileCCList", ccpath); + + StringCbLength(ccpath, sizeof(thisccache) - sizeof(wchar_t) * 5, &cb_cc); + cb_cc += sizeof(wchar_t); + + rv = khc_read_multi_string(csp_params, L"FileCCList", NULL, &cb_mlist); + if (rv == KHM_ERROR_TOO_LONG && cb_mlist > sizeof(wchar_t) * 2) { + cb_mlist += cb_cc; + mlist = PMALLOC(cb_mlist); + + t = cb_mlist; + rv = khc_read_multi_string(csp_params, L"FileCCList", mlist, &t); +#ifdef DEBUG + assert(KHM_SUCCEEDED(rv)); +#endif + if (KHM_FAILED(rv)) + goto failed_filecclist; + + if (multi_string_find(mlist, ccpath, 0) == NULL) { + t = cb_mlist; + multi_string_append(mlist, &t, ccpath); + + khc_write_multi_string(csp_params, L"FileCCList", mlist); + _reportf(L"Added CCache to list"); + } else { + _reportf(L"The CCache is already in the list"); + } + } else { + cb_mlist = cb_cc + sizeof(wchar_t); + mlist = PMALLOC(cb_mlist); + + multi_string_init(mlist, cb_mlist); + t = cb_mlist; + multi_string_append(mlist, &t, ccpath); + + khc_write_multi_string(csp_params, L"FileCCList", mlist); + + _reportf(L"FileCCList was empty. Added CCache"); + } + + failed_filecclist: + + if (mlist) + PFREE(mlist); + + } while(FALSE); + /* as in k5_read_dlg_params, once we write the data in, the local data is no longer dirty */ d->dirty = FALSE; @@ -1456,6 +1537,7 @@ k5_prep_kinit_job(khui_new_creds * nc) g_fjob.identity = ident; g_fjob.prompt_set = 0; g_fjob.valid_principal = FALSE; + g_fjob.ccache = NULL; g_fjob.retry_if_valid_principal = FALSE; /* the value for @@ -1486,13 +1568,15 @@ k5_prep_kinit_job(khui_new_creds * nc) StringCbCopy(pdlginfo->out.ccache, sizeof(pdlginfo->out.ccache), pdlginfo->in.ccache); } else { + wchar_t ccache[MAX_PATH]; + g_fjob.ccache = NULL; + size = sizeof(ccache); - StringCbCopy(pdlginfo->out.ccache, sizeof(pdlginfo->out.ccache), - idname); + khm_krb5_get_identity_default_ccache(ident, ccache, &size); - khm_krb5_canon_cc_name(pdlginfo->out.ccache, - sizeof(pdlginfo->out.ccache)); + StringCbCopy(pdlginfo->out.ccache, sizeof(pdlginfo->out.ccache), + ccache); } t = khm_get_realm_from_princ(idname); @@ -1989,8 +2073,6 @@ k5_msg_cred_dialog(khm_int32 msg_type, } - /* we can't possibly have succeeded without a - password */ if(g_fjob.code == KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN && is_k5_identpro) { kcdb_identity_set_flags(ident, @@ -2008,6 +2090,12 @@ k5_msg_cred_dialog(khm_int32 msg_type, msg[0] = L'\0'; switch(g_fjob.code) { + case 0: + /* we succeeded. This can actually happen if + there was an external program that prompted + for credentials. */ + break; + case KRB5KDC_ERR_NAME_EXP: /* principal expired */ LoadString(hResModule, IDS_K5ERR_NAME_EXPIRED, @@ -2054,11 +2142,16 @@ k5_msg_cred_dialog(khm_int32 msg_type, k5_free_kinit_job(); - if (is_k5_identpro) - kcdb_identity_set_flags(ident, - KCDB_IDENT_FLAG_UNKNOWN, - KCDB_IDENT_FLAG_UNKNOWN); - + if (is_k5_identpro) { + if (g_fjob.code == 0) + kcdb_identity_set_flags(ident, + KCDB_IDENT_FLAG_VALID, + KCDB_IDENT_FLAG_VALID); + else + kcdb_identity_set_flags(ident, + KCDB_IDENT_FLAG_UNKNOWN, + KCDB_IDENT_FLAG_UNKNOWN); + } } else if(g_fjob.state == FIBER_STATE_KINIT) { /* this is what we want. Leave the fiber there. */ @@ -2142,12 +2235,11 @@ k5_msg_cred_dialog(khm_int32 msg_type, /* We get back here once the fiber finishes processing */ - } #ifdef DEBUG - else { + } else { assert(FALSE); - } #endif + } } else { /* we weren't in a KINIT state */ if (nc->result == KHUI_NC_RESULT_CANCEL) { @@ -2157,13 +2249,12 @@ k5_msg_cred_dialog(khm_int32 msg_type, /* g_fjob.code should have the result of the last kinit attempt. We should leave it as-is */ - } #ifdef DEBUG - else { + } else { /* unknown result */ assert(FALSE); - } #endif + } } /* special case: if there was no password entered, and @@ -2247,7 +2338,7 @@ k5_msg_cred_dialog(khm_int32 msg_type, assert(nc->n_identities > 0); assert(nc->identities[0]); - k5_write_dlg_params(d, nc->identities[0]); + k5_write_dlg_params(d, nc->identities[0], g_fjob.ccache); /* We should also quickly refresh the credentials so that the identity flags and ccache @@ -2590,7 +2681,7 @@ k5_msg_cred_dialog(khm_int32 msg_type, obtaining the ticket. */ if (nc->subtype == KMSG_CRED_NEW_CREDS) { - k5_write_dlg_params(d, nc->identities[0]); + k5_write_dlg_params(d, nc->identities[0], NULL); /* and then update the LRU too */ k5_update_LRU(nc->identities[0]); diff --git a/src/windows/identity/ui/addrchange.c b/src/windows/identity/ui/addrchange.c index 36ef2beee..3953e4f10 100644 --- a/src/windows/identity/ui/addrchange.c +++ b/src/windows/identity/ui/addrchange.c @@ -68,7 +68,6 @@ addr_change_thread(LPVOID dummy) { _end_thread: ExitThread(0); - return 0; /* unreachable */ } void diff --git a/src/windows/identity/ui/cfg_appear_wnd.c b/src/windows/identity/ui/cfg_appear_wnd.c index be7c79fff..93f72857c 100644 --- a/src/windows/identity/ui/cfg_appear_wnd.c +++ b/src/windows/identity/ui/cfg_appear_wnd.c @@ -358,7 +358,7 @@ khm_cfg_appearance_proc(HWND hwnd, } else if (wParam == MAKEWPARAM(IDC_CFG_ITALICS, BN_CLICKED)) { - d->lf_work.lfItalic = + d->lf_work.lfItalic = (BYTE) (IsDlgButtonChecked(hwnd, IDC_CFG_ITALICS) == BST_CHECKED); refresh_view(hwnd, d); diff --git a/src/windows/identity/ui/cfg_general_wnd.c b/src/windows/identity/ui/cfg_general_wnd.c index 2716818b1..f4dfa7712 100644 --- a/src/windows/identity/ui/cfg_general_wnd.c +++ b/src/windows/identity/ui/cfg_general_wnd.c @@ -225,8 +225,8 @@ refresh_view(HWND hwnd, dlg_data * d) { /* we need populate the notification action combo box control and set the current selection to match the default action. */ - if (n_khm_notifier_actions != SendDlgItemMessage(hwnd, IDC_CFG_NOTACTION, - CB_GETCOUNT, 0, 0)) { + if (n_khm_notifier_actions != (khm_size) SendDlgItemMessage(hwnd, IDC_CFG_NOTACTION, + CB_GETCOUNT, 0, 0)) { for (i=0; i < n_khm_notifier_actions; i++) { int idx; diff --git a/src/windows/identity/ui/cfg_plugins_wnd.c b/src/windows/identity/ui/cfg_plugins_wnd.c index 92f1cc06b..f0789e8d0 100644 --- a/src/windows/identity/ui/cfg_plugins_wnd.c +++ b/src/windows/identity/ui/cfg_plugins_wnd.c @@ -131,7 +131,7 @@ void update_dialog_fields(HWND hwnd, for (t = info->plugin.reg.dependencies; t && *t; t = multi_string_next(t)) { SendDlgItemMessage(hwnd, IDC_CFG_DEPS, - LB_INSERTSTRING, -1, (LPARAM) t); + LB_INSERTSTRING, (WPARAM) -1, (LPARAM) t); } if (info->plugin.reg.module) diff --git a/src/windows/identity/ui/configwnd.c b/src/windows/identity/ui/configwnd.c index 14eeb15a1..f97dc6a4e 100644 --- a/src/windows/identity/ui/configwnd.c +++ b/src/windows/identity/ui/configwnd.c @@ -1119,7 +1119,7 @@ void khm_refresh_config(void) { goto _next_cfg; } - khui_menu_insert_action(omenu, -1, action, 0); + khui_menu_insert_action(omenu, (khm_size) -1, action, 0); refresh_menu = TRUE; } diff --git a/src/windows/identity/ui/credwnd.c b/src/windows/identity/ui/credwnd.c index 5091829e0..9e4daa10a 100644 --- a/src/windows/identity/ui/credwnd.c +++ b/src/windows/identity/ui/credwnd.c @@ -33,8 +33,6 @@ khm_int32 khui_cw_flag_id; khm_int32 attr_to_action[KCDB_ATTR_MAX_ID + 1]; -khm_int32 bHideWatermarks = 0; - /* forward declarations */ static void cw_select_row_creds(khui_credwnd_tbl * tbl, int row, int selected); @@ -125,8 +123,8 @@ khm_get_cw_element_font(HDC hdc, wchar_t * name, BOOL use_default, LOGFONT * pfo if (name == NULL) { LOGFONT lf = { - -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, /* width/height */ - 0,0, /* escapement */ + 0,0, + 0,0, FW_THIN, FALSE, FALSE, @@ -138,12 +136,14 @@ khm_get_cw_element_font(HDC hdc, wchar_t * name, BOOL use_default, LOGFONT * pfo FF_SWISS, L"MS Shell Dlg"}; + lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72); + *pfont = lf; } else if (!wcscmp(name, L"FontHeader")) { LOGFONT lf = { - -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, /* width/height */ - 0,0, /* escapement */ + 0,0, + 0,0, FW_THIN, FALSE, FALSE, @@ -155,12 +155,14 @@ khm_get_cw_element_font(HDC hdc, wchar_t * name, BOOL use_default, LOGFONT * pfo FF_SWISS, L"MS Shell Dlg"}; + lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72); + *pfont = lf; } else if (!wcscmp(name, L"FontHeaderBold")) { LOGFONT lf = { - -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, /* width/height */ - 0,0, /* escapement */ + 0,0, + 0,0, FW_BOLD, FALSE, FALSE, @@ -172,12 +174,14 @@ khm_get_cw_element_font(HDC hdc, wchar_t * name, BOOL use_default, LOGFONT * pfo FF_SWISS, L"MS Shell Dlg"}; + lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72); + *pfont = lf; } else if (!wcscmp(name, L"FontNormal")) { LOGFONT lf = { - -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, /* width/height */ - 0,0, /* escapement */ + 0,0, + 0,0, FW_THIN, FALSE, FALSE, @@ -189,12 +193,14 @@ khm_get_cw_element_font(HDC hdc, wchar_t * name, BOOL use_default, LOGFONT * pfo FF_SWISS, L"MS Shell Dlg"}; + lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72); + *pfont = lf; } else if (!wcscmp(name, L"FontBold")) { LOGFONT lf = { - -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, /* width/height */ - 0,0, /* escapement */ + 0,0, + 0,0, FW_BOLD, FALSE, FALSE, @@ -206,6 +212,8 @@ khm_get_cw_element_font(HDC hdc, wchar_t * name, BOOL use_default, LOGFONT * pfo FF_SWISS, L"MS Shell Dlg"}; + lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72); + *pfont = lf; } else { @@ -499,8 +507,6 @@ cw_load_view(khui_credwnd_tbl * tbl, wchar_t * view, HWND hwnd) { &hc_cw))) return; - khc_read_int32(hc_cw, L"HideWatermarks", &bHideWatermarks); - if(KHM_FAILED(khc_open_space(hc_cw, L"Views", KHM_PERM_READ, &hc_vs))) goto _exit; @@ -719,20 +725,20 @@ _skip_col: khm_handle hc_themes = NULL; khm_handle hc_theme = NULL; - COLORREF bg_s; - COLORREF bg_normal; - COLORREF bg_gray; - COLORREF bg_hdr; - COLORREF bg_hdr_cred; - COLORREF bg_hdr_warn; - COLORREF bg_hdr_crit; - COLORREF bg_hdr_exp; - - COLORREF bg_hdr_s; - COLORREF bg_hdr_cred_s; - COLORREF bg_hdr_warn_s; - COLORREF bg_hdr_crit_s; - COLORREF bg_hdr_exp_s; + COLORREF bg_s = 0; + COLORREF bg_normal = 0; + COLORREF bg_gray = 0; + COLORREF bg_hdr = 0; + COLORREF bg_hdr_cred = 0; + COLORREF bg_hdr_warn = 0; + COLORREF bg_hdr_crit = 0; + COLORREF bg_hdr_exp = 0; + + COLORREF bg_hdr_s = 0; + COLORREF bg_hdr_cred_s = 0; + COLORREF bg_hdr_warn_s = 0; + COLORREF bg_hdr_crit_s = 0; + COLORREF bg_hdr_exp_s = 0; cbsize = sizeof(buf); if (KHM_SUCCEEDED(khc_read_string(hc_cw, L"DefaultTheme", buf, &cbsize)) && @@ -763,7 +769,7 @@ _skip_col: } else { #ifdef DEBUG assert(FALSE); -#endif +#endif } if (hc_theme) @@ -1843,8 +1849,8 @@ cw_update_outline(khui_credwnd_tbl * tbl) o->start = n_rows; o->length = 1; - o->idx_start = -1; - o->idx_end = -1; + o->idx_start = (khm_size) -1; + o->idx_end = (khm_size) -1; if (grouping[0] == tbl->n_cols - 1) o->flags |= KHUI_CW_O_NOOUTLINE; @@ -1932,8 +1938,8 @@ cw_update_outline(khui_credwnd_tbl * tbl) o->flags &= ~KHUI_CW_O_EXPAND; o->start = n_rows; o->length = 1; - o->idx_start = -1; - o->idx_end = -1; + o->idx_start = (khm_size) -1; + o->idx_end = (khm_size) -1; cw_set_tbl_row_header(tbl, n_rows, grouping[0], o); @@ -2386,8 +2392,7 @@ cw_erase_rect(HDC hdc, rlogo.right = r_wnd->right; rlogo.top = r_wnd->bottom - tbl->kbm_logo_shade.cy; rlogo.bottom = r_wnd->bottom; - if (bHideWatermarks) {rie = FALSE;} - else {rie = IntersectRect(&ri, r_erase, &rlogo);} + rie = IntersectRect(&ri, r_erase, &rlogo); } else { ZeroMemory(&rlogo, sizeof(rlogo)); ZeroMemory(&ri, sizeof(ri)); @@ -3161,7 +3166,7 @@ LRESULT cw_wm_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { khui_credwnd_tbl * tbl; - HDC hdc; + HDC hdc = NULL; PAINTSTRUCT ps; RECT r,rh; HFONT hf_old = NULL; diff --git a/src/windows/identity/ui/debugfuncs.c b/src/windows/identity/ui/debugfuncs.c index 3e30f117e..384f40ea6 100644 --- a/src/windows/identity/ui/debugfuncs.c +++ b/src/windows/identity/ui/debugfuncs.c @@ -203,7 +203,7 @@ void khm_start_file_log(void) { khm_get_file_log_path(sizeof(temppath), temppath); logfile = NULL; -#if _MSC_VER >= 1400 +#if _MSC_VER >= 1400 && __STDC_WANT_SECURE_LIB__ _wfopen_s(&logfile, temppath, L"w"); #else logfile = _wfopen(temppath, L"w"); diff --git a/src/windows/identity/ui/htwnd.c b/src/windows/identity/ui/htwnd.c index 0f951a4ae..7586b3e87 100644 --- a/src/windows/identity/ui/htwnd.c +++ b/src/windows/identity/ui/htwnd.c @@ -463,23 +463,23 @@ static int htw_parse_tag( n = 1; } else if(!_wcsnicmp(start, L"b", c - start)) { - format_push(s,d, HTW_DEFAULT, FV_BOLD, HTW_DEFAULT); + format_push(s,d, HTW_DEFAULT, FV_BOLD, (COLORREF) HTW_DEFAULT); } else if(!_wcsnicmp(start, L"/b", c - start)) { format_pop(s); } else if(!_wcsnicmp(start, L"u", c - start)) { - format_push(s,d, HTW_DEFAULT, FV_UNDERLINE, HTW_DEFAULT); + format_push(s,d, HTW_DEFAULT, FV_UNDERLINE, (COLORREF) HTW_DEFAULT); } else if(!_wcsnicmp(start, L"/u", c - start)) { format_pop(s); } else if(!_wcsnicmp(start, L"i", c - start)) { - format_push(s,d, HTW_DEFAULT, FV_ITALIC, HTW_DEFAULT); + format_push(s,d, HTW_DEFAULT, FV_ITALIC, (COLORREF) HTW_DEFAULT); } else if(!_wcsnicmp(start, L"/i", c - start)) { format_pop(s); } else if(!_wcsnicmp(start, L"large", c - start)) { - format_push(s,d,-MulDiv(HTW_LARGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, HTW_DEFAULT); + format_push(s,d,-MulDiv(HTW_LARGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, (COLORREF) HTW_DEFAULT); } else if(!_wcsnicmp(start, L"/large", c - start)) { format_pop(s); } else if(!_wcsnicmp(start, L"huge", c - start)) { - format_push(s,d,-MulDiv(HTW_HUGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, HTW_DEFAULT); + format_push(s,d,-MulDiv(HTW_HUGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, (COLORREF) HTW_DEFAULT); } else if(!_wcsnicmp(start, L"/huge", c - start)) { format_pop(s); } else if(!_wcsnicmp(start, L"center", c - start)) { @@ -610,9 +610,9 @@ static void htw_assert_style(HDC hdc, khui_htwnd_data * d, int style) lf.lfEscapement = 0; lf.lfOrientation = 0; lf.lfWeight = (d->styles[style].variation & FV_BOLD)? FW_BOLD: FW_NORMAL; - lf.lfItalic = !!(d->styles[style].variation & FV_ITALIC); - lf.lfUnderline = !!(d->styles[style].variation & FV_UNDERLINE); - lf.lfStrikeOut = !!(d->styles[style].variation & FV_STRIKEOUT); + lf.lfItalic = (BYTE) !!(d->styles[style].variation & FV_ITALIC); + lf.lfUnderline = (BYTE) !!(d->styles[style].variation & FV_UNDERLINE); + lf.lfStrikeOut = (BYTE) !!(d->styles[style].variation & FV_STRIKEOUT); lf.lfCharSet = DEFAULT_CHARSET; lf.lfOutPrecision = OUT_DEFAULT_PRECIS; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; @@ -840,7 +840,7 @@ static LRESULT htw_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) else d->flags &= ~KHUI_HTWND_VSCROLL; - l = GetWindowLongPtr(hwnd, GWL_STYLE); + l = (LONG) GetWindowLongPtr(hwnd, GWL_STYLE); l &= ~(WS_HSCROLL | WS_VSCROLL); l |= ((d->flags & KHUI_HTWND_HSCROLL) ? WS_HSCROLL : 0) | diff --git a/src/windows/identity/ui/main.c b/src/windows/identity/ui/main.c index d6e5a86e5..18b5bca84 100644 --- a/src/windows/identity/ui/main.c +++ b/src/windows/identity/ui/main.c @@ -52,6 +52,14 @@ const khm_version app_version = {KH_VERSION_LIST}; HRESULT hr_coinitialize = S_OK; +#if defined(DEBUG) && (defined(KH_BUILD_PRIVATE) || defined(KH_BUILD_SPECIAL)) + +KHMEXP void KHMAPI khcint_dump_handles(FILE * f); +KHMEXP void KHMAPI perf_dump(FILE * f); +KHMEXP void KHMAPI kmqint_dump(FILE * f); + +#endif + void khm_init_gui(void) { hr_coinitialize = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); @@ -1035,11 +1043,7 @@ int WINAPI WinMain(HINSTANCE hInstance, { FILE * f = NULL; - KHMEXP void KHMAPI khcint_dump_handles(FILE * f); - KHMEXP void KHMAPI perf_dump(FILE * f); - KHMEXP void KHMAPI kmqint_dump(FILE * f); - -#if _MSC_VER >= 1400 +#if _MSC_VER >= 1400 && __STDC_WANT_SECURE_LIB__ if (fopen_s(&f, "memleak.txt", "w") != 0) goto done_with_dump; #else diff --git a/src/windows/identity/ui/mainmenu.c b/src/windows/identity/ui/mainmenu.c index bc45bddb3..7ae6e33f1 100644 --- a/src/windows/identity/ui/mainmenu.c +++ b/src/windows/identity/ui/mainmenu.c @@ -217,7 +217,7 @@ static int refresh_menu_item(HMENU hm, khui_action * act, mii.fMask = MIIM_STATE | MIIM_ID | MIIM_FTYPE; if (!GetMenuItemInfo(hm, idx, TRUE, &mii) || ((flags & KHUI_ACTIONREF_SEP) && !(mii.fType & MFT_SEPARATOR)) || - (!(flags & KHUI_ACTIONREF_SEP) && mii.wID != act->cmd)) { + (!(flags & KHUI_ACTIONREF_SEP) && mii.wID != (WORD) act->cmd)) { add_action_to_menu(hm, ((flags & KHUI_ACTIONREF_SEP)? NULL : act), idx, flags); return 0; diff --git a/src/windows/identity/ui/mainwnd.c b/src/windows/identity/ui/mainwnd.c index f647fa095..91eeceaf4 100644 --- a/src/windows/identity/ui/mainwnd.c +++ b/src/windows/identity/ui/mainwnd.c @@ -183,14 +183,7 @@ khm_ui_cb(LPARAM lParam) { #endif /* make the call */ - if (!IsBadCodePtr(pcbdata->cb)) - pcbdata->rv = (*pcbdata->cb)(khm_hwnd_main, pcbdata->rock); - else { -#ifdef DEBUG - assert(FALSE); -#endif - pcbdata->rv = KHM_ERROR_INVALID_PARAM; - } + pcbdata->rv = (*pcbdata->cb)(khm_hwnd_main, pcbdata->rock); } @@ -293,7 +286,6 @@ khm_main_wnd_proc(HWND hwnd, case KHUI_ACTION_VIEW_REFRESH: khm_cred_refresh(); InvalidateRect(khm_hwnd_main_cred, NULL, FALSE); - khui_action_trigger(KHUI_ACTION_LAYOUT_RELOAD, NULL); /* Hack causes refresh button to work in Basic view. */ return 0; case KHUI_ACTION_PASSWD_ID: @@ -416,6 +408,7 @@ khm_main_wnd_proc(HWND hwnd, /* layout control */ case KHUI_ACTION_LAYOUT_MINI: + if (khm_main_wnd_mode == KHM_MAIN_WND_MINI) { khm_set_main_window_mode(KHM_MAIN_WND_NORMAL); } else { @@ -671,7 +664,6 @@ khm_main_wnd_proc(HWND hwnd, return kmq_wm_end(m, rv); } - return 0; case WM_KHUI_ASSIGN_COMMANDLINE_V1: { @@ -1341,7 +1333,7 @@ khm_register_main_wnd_class(void) { wc.cbWndExtra = 0; wc.hInstance = khm_hInstance; wc.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP)); - wc.hCursor = LoadCursor((HINSTANCE) NULL, MAKEINTRESOURCE(IDC_ARROW)); + wc.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW); wc.hIconSm = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE); wc.lpszMenuName = NULL; @@ -1356,7 +1348,7 @@ khm_register_main_wnd_class(void) { wc.cbWndExtra = 0; wc.hInstance = khm_hInstance; wc.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP)); - wc.hCursor = LoadCursor((HINSTANCE) NULL, MAKEINTRESOURCE(IDC_ARROW)); + wc.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW); wc.hIconSm = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE); wc.lpszMenuName = NULL; diff --git a/src/windows/identity/ui/newcredwnd.c b/src/windows/identity/ui/newcredwnd.c index afc54fa23..208678a79 100644 --- a/src/windows/identity/ui/newcredwnd.c +++ b/src/windows/identity/ui/newcredwnd.c @@ -2973,7 +2973,7 @@ void khm_register_newcredwnd_class(void) void khm_unregister_newcredwnd_class(void) { - UnregisterClass((LPWSTR) khui_newcredwnd_cls, khm_hInstance); + UnregisterClass(MAKEINTATOM(khui_newcredwnd_cls), khm_hInstance); } HWND khm_create_newcredwnd(HWND parent, khui_new_creds * c) diff --git a/src/windows/identity/ui/notifier.c b/src/windows/identity/ui/notifier.c index 8b351efb8..3c4a50456 100644 --- a/src/windows/identity/ui/notifier.c +++ b/src/windows/identity/ui/notifier.c @@ -409,7 +409,7 @@ notifier_wnd_proc(HWND hwnd, POINT pt; int menu_id; khui_menu_def * mdef; - khui_action_ref * act; + khui_action_ref * act = NULL; khm_size i, n; khm_int32 def_cmd; @@ -2451,6 +2451,7 @@ alert_bin_wnd_proc(HWND hwnd, if (in_printclient) { hdc = (HDC) wParam; + ZeroMemory(&ps, sizeof(ps)); } else { hdc = BeginPaint(hwnd, &ps); } @@ -2483,7 +2484,7 @@ alert_bin_wnd_proc(HWND hwnd, khui_alert * a; #ifndef ALERT_STATIC_BACKGROUND -#define MIX_C(v1, v2, p) (((int)v1) * p + (((int) v2) * (256 - p))) +#define MIX_C(v1, v2, p) ((COLOR16)(((int)v1) * p + (((int) v2) * (256 - p)))) #define ALPHA 50 if (in_printclient || ps.fErase) { TRIVERTEX v[2]; @@ -2516,14 +2517,14 @@ alert_bin_wnd_proc(HWND hwnd, v[1].Blue = MIX_C(GetBValue(clr), GetBValue(clr2), ALPHA); } else { clr = GetSysColor(COLOR_BTNHIGHLIGHT); - v[0].Red = ((int)GetRValue(clr)) << 8; - v[0].Green = ((int)GetGValue(clr)) << 8; - v[0].Blue = ((int)GetBValue(clr)) << 8; + v[0].Red = (COLOR16) ((int)GetRValue(clr)) << 8; + v[0].Green = (COLOR16) ((int)GetGValue(clr)) << 8; + v[0].Blue = (COLOR16) ((int)GetBValue(clr)) << 8; clr = GetSysColor(COLOR_BTNFACE); - v[1].Red = ((int)GetRValue(clr)) << 8; - v[1].Green = ((int)GetGValue(clr)) << 8; - v[1].Blue = ((int)GetBValue(clr)) << 8; + v[1].Red = (COLOR16) ((int)GetRValue(clr)) << 8; + v[1].Green = (COLOR16) ((int)GetGValue(clr)) << 8; + v[1].Blue = (COLOR16) ((int)GetBValue(clr)) << 8; } gr.UpperLeft = 0; @@ -2773,7 +2774,7 @@ ATOM khm_register_alerter_wnd_class(void) wcx.cbWndExtra = DLGWINDOWEXTRA + sizeof(LONG_PTR); wcx.hInstance = khm_hInstance; wcx.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP)); - wcx.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)); + wcx.hCursor = LoadCursor(NULL, IDC_ARROW); wcx.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); wcx.lpszMenuName = NULL; wcx.lpszClassName = KHUI_ALERTER_CLASS; @@ -2798,7 +2799,7 @@ ATOM khm_register_alert_bin_wnd_class(void) wcx.cbWndExtra = sizeof(LONG_PTR); wcx.hInstance = khm_hInstance; wcx.hIcon = NULL; - wcx.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)); + wcx.hCursor = LoadCursor(NULL, IDC_ARROW); wcx.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); wcx.lpszMenuName = NULL; wcx.lpszClassName = KHUI_ALERTBIN_CLASS; diff --git a/src/windows/identity/uilib/action.c b/src/windows/identity/uilib/action.c index 3476428ac..9fd859839 100644 --- a/src/windows/identity/uilib/action.c +++ b/src/windows/identity/uilib/action.c @@ -519,9 +519,9 @@ khui_menu_dup(khui_menu_def * src) for (i=0; iitems[i].flags & KHUI_ACTIONREF_PACTION) { - khui_menu_insert_paction(d, -1, src->items[i].p_action, src->items[i].flags); + khui_menu_insert_paction(d, (khm_size) -1, src->items[i].p_action, src->items[i].flags); } else { - khui_menu_insert_action(d, -1, src->items[i].action, 0); + khui_menu_insert_action(d, (khm_size) -1, src->items[i].action, 0); } } @@ -994,9 +994,9 @@ khui_create_global_accel_table(void) { accels = PMALLOC(sizeof(ACCEL) * khui_n_accel_global); for(i=0;ikey; + mbuf[0] = (wchar_t) def->key; mbuf[1] = L'\0'; if(FAILED(StringCbCat(buf, bufsiz, mbuf))) diff --git a/src/windows/identity/uilib/creddlg.c b/src/windows/identity/uilib/creddlg.c index eb883814f..e78ced68c 100644 --- a/src/windows/identity/uilib/creddlg.c +++ b/src/windows/identity/uilib/creddlg.c @@ -29,7 +29,6 @@ #include #include #include - #include #define CW_ALLOC_INCR 8 @@ -581,7 +580,7 @@ khuiint_trim_str(wchar_t * s, khm_size cch) { return; if (c != s && ((khm_size)(c - s)) < cch) { -#if _MSC_VER >= 1400 +#if _MSC_VER >= 1400 && __STDC_WANT_SECURE_LIB__ wmemmove_s(s, cch, c, cch - ((khm_size)(c - s))); #else memmove(s, c, (cch - ((khm_size)(c - s)))* sizeof(wchar_t)); diff --git a/src/windows/identity/uilib/khaction.h b/src/windows/identity/uilib/khaction.h index 8182682c4..cd6ad8e5e 100644 --- a/src/windows/identity/uilib/khaction.h +++ b/src/windows/identity/uilib/khaction.h @@ -217,7 +217,7 @@ typedef struct tag_khui_menu_def { } khui_menu_def; #ifdef NOEXPORT -#define CONSTMENU(c,s,i) {c,s,-1,-1,i} +#define CONSTMENU(c,s,i) {c,s,(khm_size)-1,(khm_size)-1,i} #endif /*! \brief Unspecified menu -- 2.26.2