summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/windows/identity/apiversion.txt28
-rw-r--r--src/windows/identity/config/Makefile.w2k17
-rw-r--r--src/windows/identity/config/Makefile.w3241
-rw-r--r--src/windows/identity/include/khmsgtypes.h32
-rw-r--r--src/windows/identity/kconfig/api.c19
-rw-r--r--src/windows/identity/kcreddb/credential.c8
-rw-r--r--src/windows/identity/kcreddb/credtype.c11
-rw-r--r--src/windows/identity/kcreddb/type.c18
-rw-r--r--src/windows/identity/nidmgrdll/Makefile2
-rw-r--r--src/windows/identity/plugins/common/krb5common.c1
-rw-r--r--src/windows/identity/plugins/common/krb5common.h8
-rw-r--r--src/windows/identity/plugins/krb4/Makefile1
-rw-r--r--src/windows/identity/plugins/krb4/errorfuncs.c8
-rw-r--r--src/windows/identity/plugins/krb4/krb4funcs.c125
-rw-r--r--src/windows/identity/plugins/krb4/krb4newcreds.c8
-rw-r--r--src/windows/identity/plugins/krb5/Makefile1
-rw-r--r--src/windows/identity/plugins/krb5/datarep.c30
-rw-r--r--src/windows/identity/plugins/krb5/datarep.h5
-rw-r--r--src/windows/identity/plugins/krb5/krb5configcc.c16
-rw-r--r--src/windows/identity/plugins/krb5/krb5configdlg.c27
-rw-r--r--src/windows/identity/plugins/krb5/krb5configid.c12
-rw-r--r--src/windows/identity/plugins/krb5/krb5configids.c2
-rw-r--r--src/windows/identity/plugins/krb5/krb5funcs.c55
-rw-r--r--src/windows/identity/plugins/krb5/krb5identpro.c8
-rw-r--r--src/windows/identity/plugins/krb5/krb5main.c59
-rw-r--r--src/windows/identity/plugins/krb5/krbcred.h4
-rw-r--r--src/windows/identity/plugins/krb5/lang/en_us/langres.rc2
-rw-r--r--src/windows/identity/plugins/krb5/langres.h4
-rw-r--r--src/windows/identity/ui/Makefile7
-rw-r--r--src/windows/identity/ui/credwnd.c2
-rw-r--r--src/windows/identity/ui/debugfuncs.c6
-rw-r--r--src/windows/identity/ui/htwnd.c505
-rw-r--r--src/windows/identity/ui/htwnd.h2
-rw-r--r--src/windows/identity/ui/newcredwnd.c9
-rw-r--r--src/windows/identity/uilib/action.c2
-rw-r--r--src/windows/identity/uilib/alert.c2
-rw-r--r--src/windows/identity/uilib/configui.c2
-rw-r--r--src/windows/identity/uilib/creddlg.c2
-rw-r--r--src/windows/identity/uilib/khnewcred.h88
-rw-r--r--src/windows/identity/util/perfstat.c7
40 files changed, 827 insertions, 359 deletions
diff --git a/src/windows/identity/apiversion.txt b/src/windows/identity/apiversion.txt
index 008510fba..72456acd3 100644
--- a/src/windows/identity/apiversion.txt
+++ b/src/windows/identity/apiversion.txt
@@ -120,15 +120,41 @@ Date=(TBD)
# Flag for error events to signal that the error event has been committed.
+khui_action_trigger()
+# Function for triggerring an action.
+khui_action_set_hwnd()
+# internal API. Should not be used by anyone. Basically sets the HWND that should receive event notifications from the UI library.
+KEPT_PTR
+# error library data type for pointers
+_cptr
+# type cast macro for pointer types
!khc_open_space
# name parameter is now a const string
!KCDB_ATTRNAME_ISSUE
-# Fixed typo \ No newline at end of file
+# Fixed typo
+
+!kherr_val
+# is now an inline function instead of a macro
+
+!kherr_param
+# is now a structure instead of an integer type
+
++KEPT_NONE
+# new constant signifying a NULL parameter
+
+!_int32, _uint32, _int64, _uint64, _cstr, _tstr, _cptr
+# appropriate typecasts added
+
++vnull
+# macro to insert a NULL parameter
+
+!_report_cs0, _report_cs1, _report_cs2, _report_cs3
+!_report_sr0, _report_sr1, _report_sr2, _report_sr3
+!_report_mr0, _report_mr1, _report_mr2, _report_mr3
+!_report_ts0, _report_ts1, _report_ts2, _report_ts3
+# modified to use _vnull() instead of 0 for NULL parameters
+
diff --git a/src/windows/identity/config/Makefile.w2k b/src/windows/identity/config/Makefile.w2k
index 81c33546a..4ea6b8856 100644
--- a/src/windows/identity/config/Makefile.w2k
+++ b/src/windows/identity/config/Makefile.w2k
@@ -211,11 +211,20 @@ khcwarn=$(khcwarn) /WX
ldebug=$(ldebug) /DEBUG
cdebug=$(cdebug) -Os -Zi
+# Additionally, suppress conflicting default library directives that we
+# might pull in from external libraries.
+
+!ifndef NODEBUG
+lndeflibflag=/NODEFAULTLIB:MSVCRT
+!else
+lndeflibflag=/NODEFAULTLIB:MSVCRTD
+!endif
+
khcflags=$(cdebug) $(cflags) $(incflags) $(khdefines) $(khcwarn)
-khlguiflags=$(ldebug) $(guilflags)
-khlconflags=$(ldebug) $(conlflags)
-khldllguiflags=$(ldebug) $(dlllflags)
-khldllconflags=$(ldebug) $(dlllflags)
+khlguiflags=$(ldebug) $(guilflags) $(lndeflibflag)
+khlconflags=$(ldebug) $(conlflags) $(lndeflibflag)
+khldllguiflags=$(ldebug) $(dlllflags) $(lndeflibflag)
+khldllconflags=$(ldebug) $(dlllflags) $(lndeflibflag)
!if "$(KH_RUNTIME)" == "STATIC"
khcflags=$(khcflags) $(cvarsmt)
diff --git a/src/windows/identity/config/Makefile.w32 b/src/windows/identity/config/Makefile.w32
index ed966d7b5..503e44dc1 100644
--- a/src/windows/identity/config/Makefile.w32
+++ b/src/windows/identity/config/Makefile.w32
@@ -224,11 +224,20 @@ khcwarn=$(khcwarn) /WX
ldebug=$(ldebug) /DEBUG
cdebug=$(cdebug) -Os -Zi
+# Additionally, suppress conflicting default library directives that we
+# might pull in from external libraries.
+
+!ifndef NODEBUG
+lndeflibflag=/NODEFAULTLIB:MSVCRT
+!else
+lndeflibflag=/NODEFAULTLIB:MSVCRTD
+!endif
+
khcflags=$(cdebug) $(cflags) $(incflags) $(khdefines) $(khcwarn)
-khlguiflags=$(ldebug) $(guilflags)
-khlconflags=$(ldebug) $(conlflags)
-khldllguiflags=$(ldebug) $(dlllflags)
-khldllconflags=$(ldebug) $(dlllflags)
+khlguiflags=$(ldebug) $(guilflags) $(lndeflibflag)
+khlconflags=$(ldebug) $(conlflags) $(lndeflibflag)
+khldllguiflags=$(ldebug) $(dlllflags) $(lndeflibflag)
+khldllconflags=$(ldebug) $(dlllflags) $(lndeflibflag)
!if "$(KH_RUNTIME)" == "STATIC"
khcflags=$(khcflags) $(cvarsmt)
@@ -294,4 +303,28 @@ etag::
.SUFFIXES: .h
+#
+# Manifest handling
+#
+# Starting with Visual Studio 8, the C compiler and the linker
+# generate manifests so that the applications will link with the
+# correct side-by-side DLLs at run-time. These are required for
+# correct operation under Windows XP. We also have custom manifests
+# which need to be merged with the manifests that VS creates.
+#
+# The syntax for invoking the _VC_MANIFEST_EMBED_foo macro is:
+# $(_VC_MANIFEST_EMBED_???) <any additional manifests that need to be merged in>
+#
+
+!ifndef MT
+MT=mt.exe -nologo
+!endif
+
+_VC_MANIFEST_EMBED_EXE= \
+if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest
+
+_VC_MANIFEST_EMBED_DLL=$(_VC_MANIFEST_EMBED_EXE)
+
+# End of manifest handling
+
!endif
diff --git a/src/windows/identity/include/khmsgtypes.h b/src/windows/identity/include/khmsgtypes.h
index b590e056b..686a9717f 100644
--- a/src/windows/identity/include/khmsgtypes.h
+++ b/src/windows/identity/include/khmsgtypes.h
@@ -269,21 +269,38 @@
This message notifies credentials providers that a password change
request has been received.
+ A plug-in handling this message that wishes to participate in the
+ password change operation is expected to add a
+ ::khui_new_creds_by_type to the list of participants in the
+ ::khui_new_creds structure by calling khui_cw_add_type().
+
+ The password change operation requires user interaction. Any
+ plug-ins that are participating in the operation need to provide a
+ user-interface.
+
Message parameters:
- \b vparam : pointer to a ::khui_new_creds structure
+
+ \see khui_cw_add_type(), ::khui_new_creds, ::khui_new_creds_by_type
*/
#define KMSG_CRED_PASSWORD 16
/*! \brief Initiate the process of obtaining new credentials
The UI sends this message to start the process of obtaining new
- credentials. See \ref cred_acq for more information about handling this
- message.
+ credentials. See \ref cred_acq for more information about
+ handling this message.
+
+ A plug-in handling this message that wishes to participate in the
+ new credentials acquisition operation is expected to add a
+ ::khui_new_creds_by_type to hte list of participants in the
+ ::khui_new_creds structure by calling khui_cw_add_type().
Message parameters:
- \b vparam : pointer to a ::khui_new_creds structure
- \see \ref cred_acq
+ \see \ref cred_acq, khui_cw_add_type(), ::khui_new_creds,
+ ::khui_new_creds_by_type
*/
#define KMSG_CRED_NEW_CREDS 17
@@ -292,8 +309,16 @@
This is a notification sent to individual credentials providers
that a specified identity's credentials should be renewed.
+ A plug-in handling this message that wishes to participate in the
+ renew credentials operation is expected to add a
+ ::khui_new_creds_by_type to the list of participants in the
+ ::khui_new_creds structure by calling khui_cw_add_type().
+
Message parameters:
- \b vparam : Pointer to a khui_new_creds object
+
+ \see khui_cw_add_type(), ::khui_new_creds,
+ ::khui_new_creds_by_type
*/
#define KMSG_CRED_RENEW_CREDS 18
@@ -493,7 +518,6 @@
dialog completion.
Currently, the dialog messages are:
- - ::KMSG_CRED_INITIAL_CREDS
- ::KMSG_CRED_NEW_CREDS
- ::KMSG_CRED_RENEW_CREDS
- ::KMSG_CRED_DIALOG_SETUP
diff --git a/src/windows/identity/kconfig/api.c b/src/windows/identity/kconfig/api.c
index 83aa0657c..ef182fe32 100644
--- a/src/windows/identity/kconfig/api.c
+++ b/src/windows/identity/kconfig/api.c
@@ -677,6 +677,7 @@ khcint_open_space(kconf_conf_space * parent,
HKEY pkey = NULL;
HKEY ckey = NULL;
wchar_t buf[KCONF_MAXCCH_NAME];
+ size_t cb_regpath = 0;
if(!parent)
p = conf_root;
@@ -686,10 +687,7 @@ khcint_open_space(kconf_conf_space * parent,
if(n_sname >= KCONF_MAXCCH_NAME || n_sname <= 0)
return KHM_ERROR_INVALID_PARAM;
- /* SAFE: buf: buffer size == KCONF_MAXCCH_NAME * wchar_t >
- n_sname * wchar_t */
- wcsncpy(buf, sname, n_sname);
- buf[n_sname] = L'\0';
+ StringCchCopyN(buf, ARRAYLENGTH(buf), sname, n_sname);
/* see if there is already a config space by this name. if so,
return it. Note that if the configuration space is specified
@@ -760,19 +758,18 @@ khcint_open_space(kconf_conf_space * parent,
/*SAFE: p->regpath: is valid since it was set using this same
function. */
/*SAFE: buf: see above */
- c->regpath = PMALLOC((wcslen(p->regpath) + wcslen(buf) + 2) * sizeof(wchar_t));
+ cb_regpath = (wcslen(p->regpath) + wcslen(buf) + 2) * sizeof(wchar_t);
+ c->regpath = PMALLOC(cb_regpath);
assert(c->regpath != NULL);
-#pragma warning( push )
-#pragma warning( disable: 4995 )
/*SAFE: c->regpath: allocated above to be big enough */
/*SAFE: p->regpath: see above */
- wcscpy(c->regpath, p->regpath);
- wcscat(c->regpath, L"\\");
+ StringCbCopy(c->regpath, cb_regpath, p->regpath);
+ StringCbCat(c->regpath, cb_regpath, L"\\");
+
/*SAFE: buf: see above */
- wcscat(c->regpath, buf);
-#pragma warning( pop )
+ StringCbCat(c->regpath, cb_regpath, buf);
khcint_space_hold(c);
diff --git a/src/windows/identity/kcreddb/credential.c b/src/windows/identity/kcreddb/credential.c
index 6886cc5b6..98854dab4 100644
--- a/src/windows/identity/kcreddb/credential.c
+++ b/src/windows/identity/kcreddb/credential.c
@@ -943,12 +943,18 @@ kcdb_creds_is_equal(khm_handle vcred1,
kcdb_cred_lock_read();
if(!kcdb_cred_is_active_cred(vcred1) ||
- !kcdb_cred_is_active_cred(vcred2))
+ !kcdb_cred_is_active_cred(vcred2)) {
+
+ code = FALSE;
goto _exit;
+ }
+
if(vcred1 == vcred2) {
+
code = TRUE;
goto _exit;
+
}
cred1 = vcred1;
diff --git a/src/windows/identity/kcreddb/credtype.c b/src/windows/identity/kcreddb/credtype.c
index e57b22b53..89e0175f0 100644
--- a/src/windows/identity/kcreddb/credtype.c
+++ b/src/windows/identity/kcreddb/credtype.c
@@ -281,11 +281,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_describe(
*cbbuf = s;
rv = KHM_ERROR_TOO_LONG;
} else {
-#pragma warning(push)
-#pragma warning(disable:4995)
- wcscpy(buf, str); /* str is one of the string fields in t->ct which has
- been validated when the type was registered. */
-#pragma warning(pop)
+ StringCbCopy(buf, *cbbuf, str);
*cbbuf = s;
}
} else {
@@ -321,10 +317,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_get_name(
*cbbuf = s;
rv = KHM_ERROR_TOO_LONG;
} else {
-#pragma warning(push)
-#pragma warning(disable: 4995)
- wcscpy(buf, t->ct.name); /* t->ct.name was validated when the type was registered */
-#pragma warning(pop)
+ StringCbCopy(buf, *cbbuf, t->ct.name);
*cbbuf = s;
}
} else {
diff --git a/src/windows/identity/kcreddb/type.c b/src/windows/identity/kcreddb/type.c
index baf5f9730..c1215f583 100644
--- a/src/windows/identity/kcreddb/type.c
+++ b/src/windows/identity/kcreddb/type.c
@@ -391,9 +391,11 @@ FtIntervalToString(LPFILETIME data, wchar_t * buffer, khm_size * cb_buf)
t = ibuf + wcslen(ibuf);
if(h == 1)
{
- LoadString(hinst_kcreddb, IDS_IVL_1H, t, ARRAYLENGTH(ibuf) - wcslen(ibuf));
+ LoadString(hinst_kcreddb, IDS_IVL_1H, t,
+ (int) (ARRAYLENGTH(ibuf) - wcslen(ibuf)));
} else {
- LoadString(hinst_kcreddb, IDS_IVL_H, fbuf, ARRAYLENGTH(fbuf));
+ LoadString(hinst_kcreddb, IDS_IVL_H, fbuf,
+ (int) ARRAYLENGTH(fbuf));
StringCbPrintf(t, sizeof(ibuf) - wcslen(ibuf)*sizeof(wchar_t), fbuf, h);
}
}
@@ -415,9 +417,11 @@ FtIntervalToString(LPFILETIME data, wchar_t * buffer, khm_size * cb_buf)
t = ibuf + wcslen(ibuf);
if(m == 1)
{
- LoadString(hinst_kcreddb, IDS_IVL_1M, t, ARRAYLENGTH(ibuf) - wcslen(ibuf));
+ LoadString(hinst_kcreddb, IDS_IVL_1M, t,
+ (int) (ARRAYLENGTH(ibuf) - wcslen(ibuf)));
} else {
- LoadString(hinst_kcreddb, IDS_IVL_M, fbuf, ARRAYLENGTH(fbuf));
+ LoadString(hinst_kcreddb, IDS_IVL_M, fbuf,
+ (int) ARRAYLENGTH(fbuf));
StringCbPrintf(t, sizeof(ibuf) - wcslen(ibuf)*sizeof(wchar_t), fbuf, m);
}
}
@@ -434,9 +438,11 @@ FtIntervalToString(LPFILETIME data, wchar_t * buffer, khm_size * cb_buf)
t = ibuf + wcslen(ibuf);
if(s == 1)
{
- LoadString(hinst_kcreddb, IDS_IVL_1S, t, ARRAYLENGTH(ibuf) - wcslen(ibuf));
+ LoadString(hinst_kcreddb, IDS_IVL_1S, t,
+ (int) (ARRAYLENGTH(ibuf) - wcslen(ibuf)));
} else {
- LoadString(hinst_kcreddb, IDS_IVL_S, fbuf, ARRAYLENGTH(fbuf));
+ LoadString(hinst_kcreddb, IDS_IVL_S, fbuf,
+ (int) ARRAYLENGTH(fbuf));
StringCbPrintf(t, sizeof(ibuf) - wcslen(ibuf)*sizeof(wchar_t), fbuf, s);
}
}
diff --git a/src/windows/identity/nidmgrdll/Makefile b/src/windows/identity/nidmgrdll/Makefile
index d3f50021c..701a79d7d 100644
--- a/src/windows/identity/nidmgrdll/Makefile
+++ b/src/windows/identity/nidmgrdll/Makefile
@@ -113,8 +113,10 @@ SCLIB=
$(DLLFILE): $(OBJFILES) $(RESFILES)
$(DLLGUILINK) $(LIBFILES) $(SDKLIBFILES) $(SCLIB)
+ $(_VC_MANIFEST_EMBED_DLL)
all: mkdirs $(DLLFILE)
clean::
$(RM) $(DLLFILE)
+ $(RM) $(DLLFILE).manifest
diff --git a/src/windows/identity/plugins/common/krb5common.c b/src/windows/identity/plugins/common/krb5common.c
index de1cea4ab..5ba59df4e 100644
--- a/src/windows/identity/plugins/common/krb5common.c
+++ b/src/windows/identity/plugins/common/krb5common.c
@@ -31,6 +31,7 @@
#ifdef DEBUG
#include<assert.h>
#endif
+#include<strsafe.h>
/**************************************/
/* khm_krb5_error(): */
diff --git a/src/windows/identity/plugins/common/krb5common.h b/src/windows/identity/plugins/common/krb5common.h
index bd6337192..df3db93ae 100644
--- a/src/windows/identity/plugins/common/krb5common.h
+++ b/src/windows/identity/plugins/common/krb5common.h
@@ -33,9 +33,13 @@
#ifndef NO_KRB5
int khm_krb5_error(krb5_error_code rc, LPCSTR FailedFunctionName,
- int FreeContextFlag, krb5_context *ctx,
- krb5_ccache *cache);
+ int FreeContextFlag, krb5_context *ctx,
+ krb5_ccache *cache);
+int
+khm_krb5_get_error_string(krb5_error_code rc,
+ wchar_t * buffer,
+ khm_size cb_buffer);
int khm_krb5_initialize(khm_handle ident, krb5_context *, krb5_ccache *);
diff --git a/src/windows/identity/plugins/krb4/Makefile b/src/windows/identity/plugins/krb4/Makefile
index b1ad963f0..c5226aaaa 100644
--- a/src/windows/identity/plugins/krb4/Makefile
+++ b/src/windows/identity/plugins/krb4/Makefile
@@ -70,6 +70,7 @@ $(OBJ)\krb4config.c: krbconfig.csv $(CONFDIR)\csvschema.cfg
$(DLLFILE): $(OBJFILES) $(VERRESFILE) $(MSGRESFILE)
$(DLLGUILINK) $(LIBFILES) $(SDKLIBFILES) $(SCLIB)
+ $(_VC_MANIFEST_EMBED_DLL)
all: mkdirs $(MSGRESFILE) $(DLLFILE) lang
diff --git a/src/windows/identity/plugins/krb4/errorfuncs.c b/src/windows/identity/plugins/krb4/errorfuncs.c
index 5adc66b91..f1aa63d88 100644
--- a/src/windows/identity/plugins/krb4/errorfuncs.c
+++ b/src/windows/identity/plugins/krb4/errorfuncs.c
@@ -27,6 +27,8 @@
#include<krbcred.h>
#include<kherror.h>
+#include<strsafe.h>
+
extern void (__cdecl *pinitialize_krb_error_func)();
extern void (__cdecl *pinitialize_kadm_error_table)();
@@ -89,8 +91,7 @@ LPSTR err_describe(LPSTR buf, size_t len, long code)
case kadm_err_base:
break;
default:
- strncpy(buf, com_err_msg, len);
- buf[len-1] = '\0';
+ StringCbCopyA(buf, len, com_err_msg);
return buf;
}
@@ -194,8 +195,7 @@ LPSTR err_describe(LPSTR buf, size_t len, long code)
break;
}
if(com_err_msg != buf) {
- strncpy(buf, com_err_msg, len);
- buf[len-1] = '\0';
+ StringCbCopyA(buf, len, com_err_msg);
}
cp = buf + strlen(buf);
*cp++ = '\n';
diff --git a/src/windows/identity/plugins/krb4/krb4funcs.c b/src/windows/identity/plugins/krb4/krb4funcs.c
index 8928f71fd..18c05981f 100644
--- a/src/windows/identity/plugins/krb4/krb4funcs.c
+++ b/src/windows/identity/plugins/krb4/krb4funcs.c
@@ -243,10 +243,10 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname)
{
GetWindowsDirectoryA(confname,szConfname);
confname[szConfname-1] = '\0';
- strncat(confname, "\\",sizeof(confname)-strlen(confname));
- confname[szConfname-1] = '\0';
- strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname));
- confname[szConfname-1] = '\0';
+
+ StringCchCatA(confname, szConfname, "\\");
+ StringCchCatA(confname, szConfname, KRB5_FILE);
+
return FALSE;
}
@@ -254,7 +254,7 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname)
if (configFile)
{
- strncpy(confname, *configFile, szConfname);
+ StringCchCopyA(confname, szConfname, *configFile);
pkrb5_free_config_files(configFile);
}
@@ -262,10 +262,9 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname)
{
GetWindowsDirectoryA(confname,szConfname);
confname[szConfname-1] = '\0';
- strncat(confname, "\\",sizeof(confname)-strlen(confname));
- confname[szConfname-1] = '\0';
- strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname));
- confname[szConfname-1] = '\0';
+
+ StringCchCatA(confname, szConfname, "\\");
+ StringCchCatA(confname, szConfname, KRB5_FILE);
}
return FALSE;
@@ -274,51 +273,41 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname)
BOOL
khm_get_krb4_con_file(LPSTR confname, UINT szConfname)
{
- if (hKrb5 && !hKrb4)
- { // hold krb.con where krb5.ini is located
- CHAR krbConFile[MAX_PATH]="";
- LPSTR pFind;
+ if (hKrb5 && !hKrb4) {
+ // hold krb.con where krb5.ini is located
+ CHAR krbConFile[MAX_PATH]="";
+ LPSTR pFind;
- //strcpy(krbConFile, CLeashApp::m_krbv5_profile->first_file->filename);
- if (khm_krb5_get_profile_file(krbConFile, sizeof(krbConFile)))
- {
- GetWindowsDirectoryA(krbConFile,sizeof(krbConFile));
- krbConFile[MAX_PATH-1] = '\0';
- strncat(krbConFile, "\\",sizeof(krbConFile)-strlen(krbConFile));
- krbConFile[MAX_PATH-1] = '\0';
- strncat(krbConFile, KRB5_FILE,sizeof(krbConFile)-strlen(krbConFile));
- krbConFile[MAX_PATH-1] = '\0';
- }
+ if (khm_krb5_get_profile_file(krbConFile, sizeof(krbConFile))) {
+ GetWindowsDirectoryA(krbConFile,sizeof(krbConFile));
+ krbConFile[MAX_PATH-1] = '\0';
- pFind = strrchr(krbConFile, '\\');
- if (pFind)
- {
- *pFind = 0;
- strncat(krbConFile, "\\",sizeof(krbConFile)-strlen(krbConFile));
- krbConFile[MAX_PATH-1] = '\0';
- strncat(krbConFile, KRB_FILE,sizeof(krbConFile)-strlen(krbConFile));
- krbConFile[MAX_PATH-1] = '\0';
- }
- else
- krbConFile[0] = 0;
-
- strncpy(confname, krbConFile, szConfname);
+ StringCbCatA(krbConFile, sizeof(krbConFile), "\\");
+ }
+
+ pFind = strrchr(krbConFile, '\\');
+
+ if (pFind) {
+ *pFind = '\0';
+
+ StringCbCatA(krbConFile, sizeof(krbConFile), "\\");
+ StringCbCatA(krbConFile, sizeof(krbConFile), KRB_FILE);
+ } else {
+ krbConFile[0] = '\0';
+ }
+
+ StringCchCopyA(confname, szConfname, krbConFile);
+ } else if (hKrb4) {
+ unsigned int size = szConfname;
+ memset(confname, '\0', szConfname);
+ if (!pkrb_get_krbconf2(confname, &size)) {
+ GetWindowsDirectoryA(confname,szConfname);
confname[szConfname-1] = '\0';
- }
- else if (hKrb4)
- {
- unsigned int size = szConfname;
- memset(confname, '\0', szConfname);
- if (!pkrb_get_krbconf2(confname, &size))
- { // Error has happened
- GetWindowsDirectoryA(confname,szConfname);
- confname[szConfname-1] = '\0';
- strncat(confname, "\\",szConfname-strlen(confname));
- confname[szConfname-1] = '\0';
- strncat(confname,KRB_FILE,szConfname-strlen(confname));
- confname[szConfname-1] = '\0';
- }
- }
+ StringCchCatA(confname, szConfname, "\\");
+ StringCchCatA(confname, szConfname, KRB_FILE);
+ }
+ }
+
return FALSE;
}
@@ -433,7 +422,12 @@ wchar_t * khm_krb5_get_realm_list(void)
wchar_t * d;
if (!khm_get_krb4_con_file(krb_conf,sizeof(krb_conf)) &&
- (file = fopen(krb_conf, "rt")))
+#if _MSC_VER >= 1400
+ !fopen_s(&file, krb_conf, "rt")
+#else
+ (file = fopen(krb_conf, "rt"))
+#endif
+ )
{
char lineBuf[256];
@@ -519,25 +513,32 @@ make_postfix(const char * base,
const char * postfix,
char ** rcopy)
{
- int base_size;
- int ret_size;
+ size_t base_size;
+ size_t ret_size;
char * copy = 0;
char * ret = 0;
+ size_t t;
+
+ if (FAILED(StringCbLengthA(base, STRSAFE_MAX_CCH * sizeof(char), &t)))
+ goto cleanup;
+
+ base_size = t + 1;
+
+ if (FAILED(StringCbLengthA(postfix, STRSAFE_MAX_CCH * sizeof(char), &t)))
+ goto cleanup;
+
+ ret_size = base_size + t + 1;
- base_size = (int) strlen(base) + 1;
- ret_size = base_size + (int) strlen(postfix) + 1;
copy = malloc(base_size);
ret = malloc(ret_size);
if (!copy || !ret)
goto cleanup;
- strncpy(copy, base, base_size);
- copy[base_size - 1] = 0;
-
- strncpy(ret, base, base_size);
- strncpy(ret + (base_size - 1), postfix, ret_size - (base_size - 1));
- ret[ret_size - 1] = 0;
+ StringCbCopyNA(copy, base_size, base, base_size);
+ StringCbCopyNA(ret, ret_size, base, base_size);
+ StringCbCopyNA(ret + (base_size - 1), ret_size - (base_size - 1),
+ postfix, ret_size - (base_size - 1));
cleanup:
if (!copy || !ret) {
diff --git a/src/windows/identity/plugins/krb4/krb4newcreds.c b/src/windows/identity/plugins/krb4/krb4newcreds.c
index b3dd7cea7..407c30fed 100644
--- a/src/windows/identity/plugins/krb4/krb4newcreds.c
+++ b/src/windows/identity/plugins/krb4/krb4newcreds.c
@@ -115,10 +115,15 @@ void k4_update_data(k4_dlg_data * d) {
khm_boolean k4_should_identity_get_k4(khm_handle ident) {
khm_int32 idflags = 0;
+ khm_int32 t = TRUE;
khm_handle csp_ident = NULL;
khm_handle csp_k4 = NULL;
khm_boolean get_k4 = TRUE;
+ if (KHM_SUCCEEDED(khc_read_int32(csp_params, L"Krb4NewCreds", &t)) &&
+ !t)
+ return FALSE;
+
if (KHM_FAILED(kcdb_identity_get_flags(ident, &idflags)))
return FALSE;
@@ -325,8 +330,7 @@ void k4_handle_wmnc_notify(k4_dlg_data * d,
l = (khui_htwnd_link *) lParam;
- wcsncpy(wid, l->id, l->id_len);
- wid[l->id_len] = 0;
+ StringCchCopyN(wid, ARRAYLENGTH(wid), l->id, l->id_len);
wids = wcschr(wid, L':');
if (!wids)
diff --git a/src/windows/identity/plugins/krb5/Makefile b/src/windows/identity/plugins/krb5/Makefile
index 67475ee01..cfee907b2 100644
--- a/src/windows/identity/plugins/krb5/Makefile
+++ b/src/windows/identity/plugins/krb5/Makefile
@@ -74,6 +74,7 @@ $(OBJ)\krb5config.c: krbconfig.csv $(CONFDIR)\csvschema.cfg
$(DLLFILE): $(OBJFILES) $(VERRESFILE)
$(DLLGUILINK) $(MSGRESFILE) $(LIBFILES) $(SDKLIBFILES) $(SCLIB)
+ $(_VC_MANIFEST_EMBED_DLL)
$(MSGRESFILE): $(OBJ)\krb5_msgs.rc
diff --git a/src/windows/identity/plugins/krb5/datarep.c b/src/windows/identity/plugins/krb5/datarep.c
index 97d629eb4..92eabf4da 100644
--- a/src/windows/identity/plugins/krb5/datarep.c
+++ b/src/windows/identity/plugins/krb5/datarep.c
@@ -274,6 +274,36 @@ krb5flags_toString(const void *d,
}
}
+khm_int32 KHMAPI
+kvno_toString(const void * data, khm_size cbdata,
+ wchar_t *destbuf, khm_size *pcbdestbuf,
+ khm_int32 flags)
+{
+ int resid = 0;
+ int kvno;
+ wchar_t buf[256];
+ size_t cblength;
+
+ if (cbdata != sizeof(khm_int32))
+ return KHM_ERROR_INVALID_PARAM;
+
+ kvno = *((khm_int32 *) data);
+
+ StringCbPrintf(buf, sizeof(buf), L"#%d", kvno);
+
+ StringCbLength(buf, ARRAYLENGTH(buf), &cblength);
+ cblength += sizeof(wchar_t);
+
+ if (!destbuf || *pcbdestbuf < cblength) {
+ *pcbdestbuf = cblength;
+ return KHM_ERROR_TOO_LONG;
+ } else {
+ StringCbCopy(destbuf, *pcbdestbuf, buf);
+ *pcbdestbuf = cblength;
+ return KHM_ERROR_SUCCESS;
+ }
+}
+
khm_int32
serialize_krb5_addresses(krb5_address ** a, void * buf, size_t * pcbbuf)
{
diff --git a/src/windows/identity/plugins/krb5/datarep.h b/src/windows/identity/plugins/krb5/datarep.h
index eeb6970da..90f1923fa 100644
--- a/src/windows/identity/plugins/krb5/datarep.h
+++ b/src/windows/identity/plugins/krb5/datarep.h
@@ -60,6 +60,11 @@ krb5flags_toString(const void *, khm_size, wchar_t *,
khm_size *, khm_int32);
khm_int32 KHMAPI
+kvno_toString(const void * data, khm_size cbdata,
+ wchar_t *destbuf, khm_size *pcbdestbuf,
+ khm_int32 flags);
+
+khm_int32 KHMAPI
renew_for_cb(khm_handle cred, khm_int32 id, void * buffer,
khm_size * pcbsize);
diff --git a/src/windows/identity/plugins/krb5/krb5configcc.c b/src/windows/identity/plugins/krb5/krb5configcc.c
index 66e7a08d0..425d13430 100644
--- a/src/windows/identity/plugins/krb5/krb5configcc.c
+++ b/src/windows/identity/plugins/krb5/krb5configcc.c
@@ -29,16 +29,16 @@
#define _WIN32_WINNT 0x501
#endif
+#define STRSAFE_NO_DEPRECATE
+
#include<krbcred.h>
#include<krb5.h>
#include<assert.h>
#include<lm.h>
#include<commctrl.h>
-
-#pragma warning(push)
-#pragma warning(disable: 4995)
#include<shlwapi.h>
-#pragma warning(pop)
+
+#include<strsafe.h>
typedef struct tag_k5_file_cc {
wchar_t path[MAX_PATH];
@@ -97,7 +97,7 @@ void k5_add_file_cc(k5_ccc_data * d, wchar_t * path) {
/* see if it's there first */
for (i=0; i < d->n_file_ccs; i++) {
- if(!wcsicmp(d->file_ccs[i].path, path))
+ if(!_wcsicmp(d->file_ccs[i].path, path))
return;
}
@@ -232,7 +232,7 @@ BOOL k5_ccc_get_mod(k5_ccc_dlg_data * d) {
for (i=0; i < d->work.n_file_ccs; i++) {
for (j=0; j < d->save.n_file_ccs; j++) {
- if (!wcsicmp(d->work.file_ccs[i].path,
+ if (!_wcsicmp(d->work.file_ccs[i].path,
d->save.file_ccs[j].path))
break;
}
@@ -372,7 +372,7 @@ k5_ccconfig_dlgproc(HWND hwnd,
return TRUE; /* nothing to add */
for (i=0; i < d->work.n_file_ccs; i++) {
- if (!wcsicmp(path, d->work.file_ccs[i].path)) {
+ if (!_wcsicmp(path, d->work.file_ccs[i].path)) {
/* allow the user to correct case, as appropriate */
StringCbCopy(d->work.file_ccs[i].path,
@@ -522,7 +522,7 @@ k5_ccconfig_dlgproc(HWND hwnd,
LVNI_SELECTED)) != -1) {
ListView_GetItemText(lv, lv_idx, 0, buf, ARRAYLENGTH(buf));
for (i=0; i < d->work.n_file_ccs; i++) {
- if (!wcsicmp(buf, d->work.file_ccs[i].path)) {
+ if (!_wcsicmp(buf, d->work.file_ccs[i].path)) {
k5_del_file_cc(&d->work, i);
break;
}
diff --git a/src/windows/identity/plugins/krb5/krb5configdlg.c b/src/windows/identity/plugins/krb5/krb5configdlg.c
index ad64d4883..65f010840 100644
--- a/src/windows/identity/plugins/krb5/krb5configdlg.c
+++ b/src/windows/identity/plugins/krb5/krb5configdlg.c
@@ -24,17 +24,16 @@
/* $Id$ */
+#define STRSAFE_NO_DEPRECATE
+
#include<krbcred.h>
#include<krb5.h>
#include<assert.h>
#include<lm.h>
#include<commctrl.h>
-
-#pragma warning(push)
-#pragma warning(disable: 4995)
#include<shlwapi.h>
-#pragma warning(pop)
+#include<strsafe.h>
typedef struct tag_k5_realm_kdc {
wchar_t name[K5_MAXCCH_HOST];
@@ -134,12 +133,12 @@ k5_parse_boolean(const char *s)
const char *const *p;
for(p=conf_yes; *p; p++) {
- if (!stricmp(*p,s))
+ if (!_stricmp(*p,s))
return 1;
}
for(p=conf_no; *p; p++) {
- if (!stricmp(*p,s))
+ if (!_stricmp(*p,s))
return 0;
}
@@ -409,7 +408,7 @@ k5_read_config_data(k5_config_data * d) {
sizeof(kdc_name), values[i]);
for (j=0; j < d->realms[s].n_kdcs; j++)
- if (!wcsicmp(kdc_name, d->realms[s].kdcs[j].name))
+ if (!_wcsicmp(kdc_name, d->realms[s].kdcs[j].name))
break;
if (j < d->realms[s].n_kdcs) {
@@ -436,7 +435,7 @@ k5_read_config_data(k5_config_data * d) {
AnsiStrToUnicode(kdc_name, sizeof(kdc_name), values[i]);
for (j=0; j < d->realms[s].n_kdcs; j++)
- if (!wcsicmp(kdc_name, d->realms[s].kdcs[j].name))
+ if (!_wcsicmp(kdc_name, d->realms[s].kdcs[j].name))
break;
if (j < d->realms[s].n_kdcs) {
@@ -478,7 +477,7 @@ k5_read_config_data(k5_config_data * d) {
AnsiStrToUnicode(wdr_to, sizeof(wdr_to), dr_to);
for (j=0; j < d->n_realms; j++) {
- if (!wcsicmp(wdr_to, d->realms[j].realm))
+ if (!_wcsicmp(wdr_to, d->realms[j].realm))
break;
}
@@ -588,7 +587,7 @@ k5_write_config_data(k5_config_data * d) {
UnicodeStrToAnsi(astr, sizeof(astr), d->config_file);
- if (stricmp(config_file, astr)) {
+ if (_stricmp(config_file, astr)) {
assert(FALSE);
}
@@ -1965,7 +1964,7 @@ k5_realms_dlgproc(HWND hwnd,
(d->realms[i].flags & K5_RDFLAG_DELETED))
continue;
- if (!wcsicmp(d->realms[i].realm, pdisp->item.pszText))
+ if (!_wcsicmp(d->realms[i].realm, pdisp->item.pszText))
break;
}
@@ -2084,7 +2083,7 @@ k5_realms_dlgproc(HWND hwnd,
(d->realms[r].kdcs[k].flags & K5_RKFLAG_DELETED))
continue;
- if (!wcsicmp(d->realms[r].kdcs[k].name,
+ if (!_wcsicmp(d->realms[r].kdcs[k].name,
pdisp->item.pszText))
break;
}
@@ -2283,8 +2282,8 @@ k5_realms_dlgproc(HWND hwnd,
(d->realms[r].domain_maps[m].flags & K5_DMFLAG_DELETED))
continue;
- if (!wcsicmp(d->realms[r].domain_maps[m].name,
- pdisp->item.pszText))
+ if (!_wcsicmp(d->realms[r].domain_maps[m].name,
+ pdisp->item.pszText))
break;
}
diff --git a/src/windows/identity/plugins/krb5/krb5configid.c b/src/windows/identity/plugins/krb5/krb5configid.c
index ccc38941a..ebec91e99 100644
--- a/src/windows/identity/plugins/krb5/krb5configid.c
+++ b/src/windows/identity/plugins/krb5/krb5configid.c
@@ -24,16 +24,16 @@
/* $Id$ */
+#define STRSAFE_NO_DEPRECATE
+
#include<krbcred.h>
#include<krb5.h>
#include<assert.h>
#include<lm.h>
#include<commctrl.h>
-
-#pragma warning(push)
-#pragma warning(disable: 4995)
#include<shlwapi.h>
-#pragma warning(pop)
+
+#include<strsafe.h>
typedef struct tag_k5_id_dlg_data {
khui_config_init_data cfg;
@@ -164,7 +164,7 @@ k5_id_is_mod(HWND hw, k5_id_dlg_data * d) {
SendDlgItemMessage(hw, IDC_CFG_PUBLICIP, IPM_GETADDRESS,
0, (LPARAM) &dwaddress);
- if (wcsicmp(ccache, d->ccache) ||
+ if (_wcsicmp(ccache, d->ccache) ||
d->tc_renew.current != d->renew_life ||
@@ -259,7 +259,7 @@ k5_id_write_params(HWND hw, k5_id_dlg_data * d) {
GetDlgItemText(hw, IDC_CFG_CCACHE, ccache, ARRAYLENGTH(ccache));
if (SUCCEEDED(StringCbLength(ccache, sizeof(ccache), &cb)) &&
- wcsicmp(ccache, d->ccache)) {
+ _wcsicmp(ccache, d->ccache)) {
khc_write_string(csp_ident, L"DefaultCCName", ccache);
StringCbCopy(d->ccache, sizeof(d->ccache), ccache);
} else {
diff --git a/src/windows/identity/plugins/krb5/krb5configids.c b/src/windows/identity/plugins/krb5/krb5configids.c
index 4eebb9c62..579b9f712 100644
--- a/src/windows/identity/plugins/krb5/krb5configids.c
+++ b/src/windows/identity/plugins/krb5/krb5configids.c
@@ -24,6 +24,8 @@
/* $Id$ */
+#define STRSAFE_NO_DEPRECATE
+
#include<krbcred.h>
#include<krb5.h>
#include<assert.h>
diff --git a/src/windows/identity/plugins/krb5/krb5funcs.c b/src/windows/identity/plugins/krb5/krb5funcs.c
index dab522c5d..1f7b2bdad 100644
--- a/src/windows/identity/plugins/krb5/krb5funcs.c
+++ b/src/windows/identity/plugins/krb5/krb5funcs.c
@@ -434,12 +434,15 @@ static long get_tickets_from_cache(krb5_context ctx,
if ( !pkrb5_decode_ticket(&KRBv5Credentials.ticket, &tkt)) {
ti = tkt->enc_part.enctype;
kcdb_cred_set_attr(cred, attr_id_tkt_enctype, &ti, sizeof(ti));
+ ti = tkt->enc_part.kvno;
+ kcdb_cred_set_attr(cred, attr_id_kvno, &ti, sizeof(ti));
pkrb5_free_ticket(ctx, tkt);
tkt = NULL;
}
ti = KRBv5Credentials.keyblock.enctype;
kcdb_cred_set_attr(cred, attr_id_key_enctype, &ti, sizeof(ti));
+
kcdb_cred_set_attr(cred, KCDB_ATTR_LOCATION, wcc_name,
KCDB_CBSIZE_AUTO);
@@ -1734,10 +1737,10 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname)
{
GetWindowsDirectoryA(confname,szConfname);
confname[szConfname-1] = '\0';
- strncat(confname, "\\",sizeof(confname)-strlen(confname));
- confname[szConfname-1] = '\0';
- strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname));
- confname[szConfname-1] = '\0';
+
+ StringCchCatA(confname, szConfname, "\\");
+ StringCchCatA(confname, szConfname, KRB5_FILE);
+
return FALSE;
}
@@ -1745,7 +1748,7 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname)
if (configFile)
{
- strncpy(confname, *configFile, szConfname);
+ StringCchCopyA(confname, szConfname, *configFile);
pkrb5_free_config_files(configFile);
}
@@ -1753,10 +1756,8 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname)
{
GetWindowsDirectoryA(confname,szConfname);
confname[szConfname-1] = '\0';
- strncat(confname, "\\",sizeof(confname)-strlen(confname));
- confname[szConfname-1] = '\0';
- strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname));
- confname[szConfname-1] = '\0';
+ StringCchCatA(confname, szConfname, "\\");
+ StringCchCatA(confname, szConfname, KRB5_FILE);
}
return FALSE;
@@ -1773,25 +1774,19 @@ khm_get_krb4_con_file(LPSTR confname, UINT szConfname)
if (khm_krb5_get_profile_file(krbConFile, sizeof(krbConFile))) {
GetWindowsDirectoryA(krbConFile,sizeof(krbConFile));
krbConFile[MAX_PATH-1] = '\0';
- strncat(krbConFile, "\\",sizeof(krbConFile)-strlen(krbConFile));
- krbConFile[MAX_PATH-1] = '\0';
- strncat(krbConFile, KRB5_FILE,sizeof(krbConFile)-strlen(krbConFile));
- krbConFile[MAX_PATH-1] = '\0';
+ StringCchCatA(confname, szConfname, "\\");
}
pFind = strrchr(krbConFile, '\\');
if (pFind) {
- *pFind = 0;
- strncat(krbConFile, "\\",sizeof(krbConFile)-strlen(krbConFile));
- krbConFile[MAX_PATH-1] = '\0';
- strncat(krbConFile, KRB_FILE,sizeof(krbConFile)-strlen(krbConFile));
- krbConFile[MAX_PATH-1] = '\0';
+ *pFind = '\0';
+ StringCchCatA(krbConFile, ARRAYLENGTH(krbConFile), "\\");
+ StringCchCatA(krbConFile, ARRAYLENGTH(krbConFile), KRB_FILE);
}
else
- krbConFile[0] = 0;
-
- strncpy(confname, krbConFile, szConfname);
- confname[szConfname-1] = '\0';
+ krbConFile[0] = '\0';
+
+ StringCchCopyA(confname, szConfname, krbConFile);
}
else if (hKrb4) {
unsigned int size = szConfname;
@@ -1800,10 +1795,8 @@ khm_get_krb4_con_file(LPSTR confname, UINT szConfname)
{ // Error has happened
GetWindowsDirectoryA(confname,szConfname);
confname[szConfname-1] = '\0';
- strncat(confname, "\\",szConfname-strlen(confname));
- confname[szConfname-1] = '\0';
- strncat(confname,KRB_FILE,szConfname-strlen(confname));
- confname[szConfname-1] = '\0';
+ StringCchCatA(confname, szConfname, "\\");
+ StringCchCatA(confname, szConfname, KRB_FILE);
}
}
return FALSE;
@@ -1922,7 +1915,12 @@ khm_krb5_get_realm_list(void)
wchar_t * d;
if (!khm_get_krb4_con_file(krb_conf,sizeof(krb_conf)) &&
- (file = fopen(krb_conf, "rt")))
+#if _MSC_VER >= 1400
+ !fopen_s(&file, krb_conf, "rt")
+#else
+ (file = fopen(krb_conf, "rt"))
+#endif
+ )
{
char lineBuf[256];
@@ -2151,7 +2149,8 @@ khm_int32 KHMAPI
khm_krb5_creds_is_equal(khm_handle vcred1, khm_handle vcred2, void * dummy) {
if (kcdb_creds_comp_attr(vcred1, vcred2, KCDB_ATTR_LOCATION) ||
kcdb_creds_comp_attr(vcred1, vcred2, attr_id_key_enctype) ||
- kcdb_creds_comp_attr(vcred1, vcred2, attr_id_tkt_enctype))
+ kcdb_creds_comp_attr(vcred1, vcred2, attr_id_tkt_enctype) ||
+ kcdb_creds_comp_attr(vcred1, vcred2, attr_id_kvno))
return 1;
else
return 0;
diff --git a/src/windows/identity/plugins/krb5/krb5identpro.c b/src/windows/identity/plugins/krb5/krb5identpro.c
index f52e3441d..b263e6bf3 100644
--- a/src/windows/identity/plugins/krb5/krb5identpro.c
+++ b/src/windows/identity/plugins/krb5/krb5identpro.c
@@ -212,7 +212,7 @@ update_crossfeed(khui_new_creds * nc,
(WPARAM) idx,
(LPARAM) srealm);
- if (!wcsicmp(srealm, un_realm) && wcscmp(srealm, un_realm)) {
+ if (!_wcsicmp(srealm, un_realm) && wcscmp(srealm, un_realm)) {
/* differ only by case */
StringCchCopy(un_realm, ARRAYLENGTH(un) - (un_realm - un),
@@ -260,7 +260,7 @@ update_crossfeed(khui_new_creds * nc,
(WPARAM) idx,
(LPARAM) srealm);
- if (!wcsicmp(srealm, realm) && wcscmp(srealm, realm)) {
+ if (!_wcsicmp(srealm, realm) && wcscmp(srealm, realm)) {
StringCbCopy(realm, sizeof(realm), srealm);
SetWindowText(d->hw_realm, srealm);
@@ -1145,7 +1145,7 @@ k5_ident_update(khm_int32 msg_type,
khm_krb5_canon_cc_name(w_ccname, sizeof(w_ccname));
khm_krb5_canon_cc_name(wid_ccname, sizeof(wid_ccname));
- if (!wcsicmp(w_ccname, wid_ccname))
+ if (!_wcsicmp(w_ccname, wid_ccname))
kcdb_identity_set_default_int(ident);
_iu_cleanup:
@@ -1499,7 +1499,7 @@ DWORD WINAPI k5_ccname_monitor_thread(LPVOID lpParameter) {
new_ccname[0] = L'\0';
}
- if (wcsicmp(new_ccname, reg_ccname)) {
+ if (_wcsicmp(new_ccname, reg_ccname)) {
k5_refresh_default_identity(ctx);
StringCbCopy(reg_ccname, sizeof(reg_ccname), new_ccname);
}
diff --git a/src/windows/identity/plugins/krb5/krb5main.c b/src/windows/identity/plugins/krb5/krb5main.c
index ee85355a0..97ef85ee9 100644
--- a/src/windows/identity/plugins/krb5/krb5main.c
+++ b/src/windows/identity/plugins/krb5/krb5main.c
@@ -36,23 +36,27 @@ khm_int32 type_id_enctype = -1;
khm_int32 type_id_addr_list = -1;
khm_int32 type_id_krb5_flags = -1;
khm_int32 type_id_krb5_princ = -1;
+khm_int32 type_id_kvno = -1;
BOOL type_regd_enctype = FALSE;
BOOL type_regd_addr_list = FALSE;
BOOL type_regd_krb5_flags = FALSE;
BOOL type_regd_krb5_princ = FALSE;
+BOOL type_regd_kvno = FALSE;
khm_int32 attr_id_key_enctype = -1;
khm_int32 attr_id_tkt_enctype = -1;
khm_int32 attr_id_addr_list = -1;
khm_int32 attr_id_krb5_flags = -1;
khm_int32 attr_id_krb5_ccname = -1;
+khm_int32 attr_id_kvno = -1;
BOOL attr_regd_key_enctype = FALSE;
BOOL attr_regd_tkt_enctype = FALSE;
BOOL attr_regd_addr_list = FALSE;
BOOL attr_regd_krb5_flags = FALSE;
BOOL attr_regd_krb5_ccname = FALSE;
+BOOL attr_regd_kvno = FALSE;
khm_handle csp_plugins = NULL;
khm_handle csp_krbcred = NULL;
@@ -196,6 +200,31 @@ KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module) {
type_regd_krb5_flags = TRUE;
}
+ if (KHM_FAILED(kcdb_type_get_id(TYPENAME_KVNO, &type_id_kvno))) {
+ kcdb_type type;
+ kcdb_type *t32;
+
+ kcdb_type_get_info(KCDB_TYPE_INT32, &t32);
+
+ type.id = KCDB_TYPE_INVALID;
+ type.name = TYPENAME_KVNO;
+ type.flags = KCDB_TYPE_FLAG_CB_FIXED;
+ type.cb_max = t32->cb_max;
+ type.cb_min = t32->cb_min;
+ type.isValid = t32->isValid;
+ type.comp = t32->comp;
+ type.dup = t32->dup;
+ type.toString = kvno_toString;
+
+ rv = kcdb_type_register(&type, &type_id_kvno);
+ kcdb_type_release_info(t32);
+
+ if (KHM_FAILED(rv))
+ goto _exit;
+
+ type_regd_kvno = TRUE;
+ }
+
/* Register common attributes */
if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_KEY_ENCTYPE, &attr_id_key_enctype))) {
kcdb_attrib attrib;
@@ -328,6 +357,32 @@ KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module) {
attr_regd_krb5_ccname = TRUE;
}
+ if (KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_KVNO, &attr_id_kvno))) {
+ kcdb_attrib attrib;
+ wchar_t sbuf[KCDB_MAXCCH_SHORT_DESC];
+ wchar_t lbuf[KCDB_MAXCCH_LONG_DESC];
+ /* although we are loading a long description, it still fits
+ in the short description buffer */
+
+ ZeroMemory(&attrib, sizeof(attrib));
+
+ attrib.name = ATTRNAME_KVNO;
+ attrib.id = KCDB_ATTR_INVALID;
+ attrib.type = type_id_kvno;
+ attrib.flags = KCDB_ATTR_FLAG_TRANSIENT;
+ LoadString(hResModule, IDS_KVNO_SHORT_DESC, sbuf, ARRAYLENGTH(sbuf));
+ LoadString(hResModule, IDS_KVNO_LONG_DESC, lbuf, ARRAYLENGTH(lbuf));
+ attrib.short_desc = sbuf;
+ attrib.long_desc = lbuf;
+
+ rv = kcdb_attrib_register(&attrib, &attr_id_kvno);
+
+ if (KHM_FAILED(rv))
+ goto _exit;
+
+ attr_regd_kvno = TRUE;
+ }
+
rv = kmm_get_plugins_config(0, &csp_plugins);
if(KHM_FAILED(rv)) goto _exit;
@@ -359,6 +414,8 @@ KHMEXP khm_int32 KHMAPI exit_module(kmm_module h_module) {
kcdb_attrib_unregister(attr_id_krb5_flags);
if(attr_regd_krb5_ccname)
kcdb_attrib_unregister(attr_id_krb5_ccname);
+ if(attr_regd_kvno)
+ kcdb_attrib_unregister(attr_id_kvno);
if(type_regd_enctype)
kcdb_type_unregister(type_id_enctype);
@@ -366,6 +423,8 @@ KHMEXP khm_int32 KHMAPI exit_module(kmm_module h_module) {
kcdb_type_unregister(type_id_addr_list);
if(type_regd_krb5_flags)
kcdb_type_unregister(type_id_krb5_flags);
+ if(type_regd_kvno)
+ kcdb_type_unregister(type_id_kvno);
if(csp_params) {
khc_close_space(csp_params);
diff --git a/src/windows/identity/plugins/krb5/krbcred.h b/src/windows/identity/plugins/krb5/krbcred.h
index 3e64b0077..4b9373d08 100644
--- a/src/windows/identity/plugins/krb5/krbcred.h
+++ b/src/windows/identity/plugins/krb5/krbcred.h
@@ -62,12 +62,14 @@ typedef enum tag_k5_lsa_import {
#define TYPENAME_ADDR_LIST L"AddrList"
#define TYPENAME_KRB5_FLAGS L"Krb5Flags"
#define TYPENAME_KRB5_PRINC L"Krb5Principal"
+#define TYPENAME_KVNO L"Kvno"
#define ATTRNAME_KEY_ENCTYPE L"KeyEncType"
#define ATTRNAME_TKT_ENCTYPE L"TktEncType"
#define ATTRNAME_ADDR_LIST L"AddrList"
#define ATTRNAME_KRB5_FLAGS L"Krb5Flags"
#define ATTRNAME_KRB5_CCNAME L"Krb5CCName"
+#define ATTRNAME_KVNO L"Kvno"
void init_krb();
void exit_krb();
@@ -84,6 +86,7 @@ extern khm_int32 type_id_enctype;
extern khm_int32 type_id_addr_list;
extern khm_int32 type_id_krb5_flags;
extern khm_int32 type_id_krb5_princ;
+extern khm_int32 type_id_kvno;
extern BOOL type_regd_krb5_princ;
@@ -92,6 +95,7 @@ extern khm_int32 attr_id_tkt_enctype;
extern khm_int32 attr_id_addr_list;
extern khm_int32 attr_id_krb5_flags;
extern khm_int32 attr_id_krb5_ccname;
+extern khm_int32 attr_id_kvno;
extern khm_ui_4 k5_commctl_version;
diff --git a/src/windows/identity/plugins/krb5/lang/en_us/langres.rc b/src/windows/identity/plugins/krb5/lang/en_us/langres.rc
index c54bdb4b1..49673c378 100644
--- a/src/windows/identity/plugins/krb5/lang/en_us/langres.rc
+++ b/src/windows/identity/plugins/krb5/lang/en_us/langres.rc
@@ -521,6 +521,8 @@ BEGIN
IDS_CFG_RE_MMK "Toggle &master KDC"
IDS_CFG_RE_MND "&Add new domain mapping"
IDS_CFG_RE_MDD "&Remove domain mapping"
+ IDS_KVNO_LONG_DESC "Key version number"
+ IDS_KVNO_SHORT_DESC "Kvno"
END
#endif // English (U.S.) resources
diff --git a/src/windows/identity/plugins/krb5/langres.h b/src/windows/identity/plugins/krb5/langres.h
index edda7dd02..da8a62ffd 100644
--- a/src/windows/identity/plugins/krb5/langres.h
+++ b/src/windows/identity/plugins/krb5/langres.h
@@ -132,6 +132,8 @@
#define IDS_CFG_RE_MMK 214
#define IDS_CFG_RE_MND 215
#define IDS_CFG_RE_MDD 216
+#define IDS_KVNO_SHORT_DESC 217
+#define IDS_KVNO_LONG_DESC 218
#define IDC_NCK5_RENEWABLE 1002
#define IDC_NCK5_FORWARDABLE 1004
#define IDC_NCK5_REALM 1005
@@ -204,7 +206,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 118
+#define _APS_NEXT_RESOURCE_VALUE 219
#define _APS_NEXT_COMMAND_VALUE 40002
#define _APS_NEXT_CONTROL_VALUE 1079
#define _APS_NEXT_SYMED_VALUE 101
diff --git a/src/windows/identity/ui/Makefile b/src/windows/identity/ui/Makefile
index e09d9f8c7..35c19bdba 100644
--- a/src/windows/identity/ui/Makefile
+++ b/src/windows/identity/ui/Makefile
@@ -27,7 +27,7 @@ MODULE=ui
EXEFILE=$(BINDIR)\netidmgr.exe
-MANIFESTFILE=$(BINDIR)\netidmgr.exe.manifest
+MANIFESTFILE=$(BINDIR)\netidmgr.exe.static.manifest
OBJFILES= \
$(OBJ)\main.obj \
@@ -88,7 +88,6 @@ $(MANIFESTFILE): netidmgr.manifest.$(CPU).$(KH_CLVER).debug
!endif
$(CP) $** $@
-
!if ("$(CPU)" == "IA64" ) || ("$(CPU)" == "AMD64" ) || ("$(CPU)" == "ALPHA64" )
SCLIB=bufferoverflowu.lib
!else
@@ -97,6 +96,6 @@ SCLIB=
$(EXEFILE): $(OBJFILES) $(RESFILES) $(LIBFILES)
$(EXEGUILINK) $(SDKLIBFILES) $(SCLIB)
+ $(_VC_MANIFEST_EMBED_EXE) $(MANIFESTFILE)
-all: mkdirs $(EXEFILE) $(MANIFESTFILE)
-
+all: mkdirs $(MANIFESTFILE) $(EXEFILE)
diff --git a/src/windows/identity/ui/credwnd.c b/src/windows/identity/ui/credwnd.c
index b68a3f953..31df6bdf7 100644
--- a/src/windows/identity/ui/credwnd.c
+++ b/src/windows/identity/ui/credwnd.c
@@ -4113,7 +4113,7 @@ cw_wm_command(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
/* a hyperlink was activated */
khui_htwnd_link * l;
l = (khui_htwnd_link *) lParam;
- wcsncpy(wid, l->id, l->id_len);
+ StringCchCopyN(wid, ARRAYLENGTH(wid), l->id, l->id_len);
wid[l->id_len] = 0;
if(!wcscmp(wid, L"NewCreds")) {
diff --git a/src/windows/identity/ui/debugfuncs.c b/src/windows/identity/ui/debugfuncs.c
index b18ef42bb..7df6e9d65 100644
--- a/src/windows/identity/ui/debugfuncs.c
+++ b/src/windows/identity/ui/debugfuncs.c
@@ -202,8 +202,12 @@ void khm_start_file_log(void) {
khm_get_file_log_path(sizeof(temppath), temppath);
+ logfile = NULL;
+#if _MSC_VER >= 1400
+ _wfopen_s(&logfile, temppath, L"w");
+#else
logfile = _wfopen(temppath, L"w");
-
+#endif
kherr_add_ctx_handler(debug_event_handler,
KHERR_CTX_BEGIN |
KHERR_CTX_END |
diff --git a/src/windows/identity/ui/htwnd.c b/src/windows/identity/ui/htwnd.c
index a9472585b..9507fbdd0 100644
--- a/src/windows/identity/ui/htwnd.c
+++ b/src/windows/identity/ui/htwnd.c
@@ -121,6 +121,8 @@ typedef struct khui_htwnd_data_t {
wchar_t * text;
int scroll_left;
int scroll_top;
+ int ext_width;
+ int ext_height;
COLORREF bk_color;
HCURSOR hc_hand;
int l_pixel_y;
@@ -630,6 +632,8 @@ static LRESULT htw_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
int align;
int y;
wchar_t * par_start;
+ int ext_width = 0;
+ int ext_height = 0;
d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
@@ -645,8 +649,11 @@ static LRESULT htw_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
GetClientRect(hwnd, &r);
+#ifdef DRAW_HTWND_CLIENT_EDGE
+ /* for the moment, we are skipping on the client edge. */
if(d->flags & KHUI_HTWND_CLIENTEDGE)
DrawEdge(hdc, &r, EDGE_SUNKEN, BF_ADJUST | BF_RECT | BF_FLAT);
+#endif
hbk = CreateSolidBrush(RGB(255,255,255));
FillRect(hdc, &r, hbk);
@@ -728,8 +735,6 @@ static LRESULT htw_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
p = par_start;
format_unwind(&s_stack, s_start); /* unwind format stack */
- //MoveToEx(hdc, x, y + l_height, NULL);
-
p_width = 0;
while(*p) {
@@ -766,13 +771,14 @@ static LRESULT htw_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
SetTextColor(hdc, format_color(&s_stack));
GetTextExtentPoint32(hdc, p, (int)(c - p), &s);
- rd.left = x + p_width;
- rd.top = y;
- rd.right = x + p_width + s.cx;
- rd.bottom = y + l_height;
+ rd.left = x + p_width - d->scroll_left;
+ rd.top = y - d->scroll_top;
+ rd.right = x + p_width + s.cx - d->scroll_left;
+ rd.bottom = y + l_height - d->scroll_top;
if(IntersectRect(&rt, &rd, &r)) {
- DrawText(hdc, p, (int)(c - p), &rt, DT_BOTTOM | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
+ DrawText(hdc, p, (int)(c - p), &rd,
+ DT_BOTTOM | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
}
p_width += s.cx;
@@ -782,12 +788,86 @@ static LRESULT htw_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
}
+ if (p_width > ext_width)
+ ext_width = p_width;
+
y += l_height;
par_start = p;
}
+ if (y > ext_height)
+ ext_height = y;
+
EndPaint(hwnd, &ps);
+ if (d->ext_width < ext_width) {
+ SCROLLINFO si;
+ LONG l;
+
+ /* the extents need to be adjusted. But first check if we
+ have exactly the right scroll bars we need. */
+ if ((ext_width > (r.right - r.left) &&
+ !(d->flags & KHUI_HTWND_HSCROLL)) ||
+ (ext_height > (r.bottom - r.top) &&
+ !(d->flags & KHUI_HTWND_VSCROLL)) ||
+
+ (ext_width <= (r.right - r.left) &&
+ (d->flags & KHUI_HTWND_HSCROLL)) ||
+ (ext_height <= (r.bottom - r.top) &&
+ (d->flags & KHUI_HTWND_VSCROLL))) {
+
+ /* need to add scroll bars */
+ if (ext_width > (r.right - r.left))
+ d->flags |= KHUI_HTWND_HSCROLL;
+ else
+ d->flags &= ~KHUI_HTWND_HSCROLL;
+
+ if (ext_height > (r.bottom - r.top))
+ d->flags |= KHUI_HTWND_VSCROLL;
+ else
+ d->flags &= ~KHUI_HTWND_VSCROLL;
+
+ l = GetWindowLongPtr(hwnd, GWL_STYLE);
+ l &= ~(WS_HSCROLL | WS_VSCROLL);
+
+ l |= ((d->flags & KHUI_HTWND_HSCROLL) ? WS_HSCROLL : 0) |
+ ((d->flags & KHUI_HTWND_VSCROLL) ? WS_VSCROLL : 0);
+
+ SetWindowLongPtr(hwnd, GWL_STYLE, l);
+
+ InvalidateRect(hwnd, NULL, FALSE);
+ /* since the client area changed, we do another redraw
+ before updating the scroll bar positions. */
+ } else {
+ d->ext_width = ext_width;
+ d->ext_height = ext_height;
+
+ if (d->flags & KHUI_HTWND_HSCROLL) {
+ ZeroMemory(&si, sizeof(si));
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
+ si.nMin = 0;
+ si.nMax = ext_width;
+ si.nPage = r.right - r.left;
+ si.nPos = d->scroll_left;
+
+ SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
+ }
+
+ if (d->flags & KHUI_HTWND_VSCROLL) {
+ ZeroMemory(&si, sizeof(si));
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
+ si.nMin = 0;
+ si.nMax = ext_height;
+ si.nPage = r.bottom - r.top;
+ si.nPos = d->scroll_top;
+
+ SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
+ }
+ }
+ }
+
return 0;
}
@@ -798,231 +878,328 @@ LRESULT CALLBACK khui_htwnd_proc(HWND hwnd,
)
{
switch(uMsg) {
- case WM_CREATE:
- {
- CREATESTRUCT * cs;
- khui_htwnd_data * d;
- size_t cbsize;
+ case WM_CREATE:
+ {
+ CREATESTRUCT * cs;
+ khui_htwnd_data * d;
+ size_t cbsize;
- cs = (CREATESTRUCT *) lParam;
+ cs = (CREATESTRUCT *) lParam;
- d = PMALLOC(sizeof(*d));
- ZeroMemory(d, sizeof(*d));
+ d = PMALLOC(sizeof(*d));
+ ZeroMemory(d, sizeof(*d));
- if(cs->dwExStyle & WS_EX_TRANSPARENT) {
- d->flags |= KHUI_HTWND_TRANSPARENT;
- }
- if(cs->dwExStyle & WS_EX_CLIENTEDGE) {
- d->flags |= KHUI_HTWND_CLIENTEDGE;
- }
- d->id = (int)(INT_PTR) cs->hMenu;
+ if(cs->dwExStyle & WS_EX_TRANSPARENT) {
+ d->flags |= KHUI_HTWND_TRANSPARENT;
+ }
+ if(cs->dwExStyle & WS_EX_CLIENTEDGE) {
+ d->flags |= KHUI_HTWND_CLIENTEDGE;
+ }
+ if(cs->style & WS_HSCROLL) {
+ d->flags |= KHUI_HTWND_HSCROLL;
+ }
+ if(cs->style & WS_VSCROLL) {
+ d->flags |= KHUI_HTWND_VSCROLL;
+ }
+ d->id = (int)(INT_PTR) cs->hMenu;
- d->active_link = -1;
- d->bk_color = RGB(255,255,255);
- d->hc_hand = LoadCursor(NULL, IDC_HAND);
+ d->active_link = -1;
+ d->bk_color = RGB(255,255,255);
+ d->hc_hand = LoadCursor(NULL, IDC_HAND);
- if(SUCCEEDED(StringCbLength(cs->lpszName, KHUI_HTWND_MAXCB_TEXT, &cbsize))) {
- cbsize += sizeof(wchar_t);
- d->text = PMALLOC(cbsize);
- StringCbCopy(d->text, cbsize, cs->lpszName);
- }
+ if(SUCCEEDED(StringCbLength(cs->lpszName, KHUI_HTWND_MAXCB_TEXT, &cbsize))) {
+ cbsize += sizeof(wchar_t);
+ d->text = PMALLOC(cbsize);
+ StringCbCopy(d->text, cbsize, cs->lpszName);
+ }
+
+ /* this is just a flag to the WM_PAINT handler that the
+ extents haven't been set yet. */
+ d->ext_width = -1;
#pragma warning(push)
#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, 0, (LONG_PTR) d);
+ SetWindowLongPtr(hwnd, 0, (LONG_PTR) d);
#pragma warning(pop)
- return 0;
+ return 0;
+ }
+ break;
+
+ case WM_SETTEXT:
+ {
+ wchar_t * newtext;
+ size_t cbsize;
+ khui_htwnd_data * d;
+ BOOL rv;
+
+ d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
+ newtext = (wchar_t *) lParam;
+
+ if(d->text) {
+ PFREE(d->text);
+ d->text = NULL;
}
- break;
- case WM_SETTEXT:
- {
- wchar_t * newtext;
- size_t cbsize;
- khui_htwnd_data * d;
- BOOL rv;
+ if(SUCCEEDED(StringCbLength(newtext, KHUI_HTWND_MAXCB_TEXT, &cbsize))) {
+ cbsize += sizeof(wchar_t);
+ d->text = PMALLOC(cbsize);
+ StringCbCopy(d->text, cbsize, newtext);
+ rv = TRUE;
+ } else
+ rv = FALSE;
+
+ clear_styles(d);
+
+ d->ext_width = -1;
+ d->scroll_left = 0;
+ d->scroll_top = 0;
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- newtext = (wchar_t *) lParam;
+ InvalidateRect(hwnd, NULL, TRUE);
- if(d->text) {
- PFREE(d->text);
- d->text = NULL;
+ return rv;
+ }
+ break;
+
+ case WM_DESTROY:
+ {
+ khui_htwnd_data * d;
+ int i;
+
+ d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
+ if(d->text)
+ PFREE(d->text);
+ d->text = 0;
+
+ if(d->links) {
+ for(i=0;i<d->max_links;i++) {
+ if(d->links[i])
+ PFREE(d->links[i]);
}
+ PFREE(d->links);
+ }
- if(SUCCEEDED(StringCbLength(newtext, KHUI_HTWND_MAXCB_TEXT, &cbsize))) {
- cbsize += sizeof(wchar_t);
- d->text = PMALLOC(cbsize);
- StringCbCopy(d->text, cbsize, newtext);
- rv = TRUE;
- } else
- rv = FALSE;
+ clear_styles(d);
- clear_styles(d);
+ PFREE(d);
+ }
+ break;
- InvalidateRect(hwnd, NULL, TRUE);
+ case WM_ERASEBKGND:
+ {
+ khui_htwnd_data * d;
+ d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- return rv;
- }
- break;
+ if(d->flags & KHUI_HTWND_TRANSPARENT)
+ return TRUE;
- case WM_DESTROY:
- {
- khui_htwnd_data * d;
- int i;
-
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if(d->text)
- PFREE(d->text);
- d->text = 0;
-
- if(d->links) {
- for(i=0;i<d->max_links;i++) {
- if(d->links[i])
- PFREE(d->links[i]);
- }
- PFREE(d->links);
- }
+ return FALSE;
+ }
+
+ case WM_PAINT:
+ htw_paint(hwnd, uMsg, wParam, lParam);
+ break;
+
+ case WM_SETCURSOR:
+ {
+ khui_htwnd_data * d;
- clear_styles(d);
+ if(hwnd != (HWND)wParam)
+ break;
+
+ d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- PFREE(d);
+ if(d->active_link >= 0) {
+ SetCursor(d->hc_hand);
+ return TRUE;
}
- break;
+ }
+ break;
- case WM_ERASEBKGND:
- {
- khui_htwnd_data * d;
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
+ case WM_SETFOCUS:
+ {
+ khui_htwnd_data * d;
- if(d->flags & KHUI_HTWND_TRANSPARENT)
- return TRUE;
+ d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- return FALSE;
- }
+ d->flags |= KHUI_HTWND_FOCUS;
- case WM_PAINT:
- htw_paint(hwnd, uMsg, wParam, lParam);
- break;
+ InvalidateRect(hwnd, NULL, TRUE);
+ }
+ break;
- case WM_SETCURSOR:
- {
- khui_htwnd_data * d;
+ case WM_KILLFOCUS:
+ {
+ khui_htwnd_data * d;
- if(hwnd != (HWND)wParam)
- break;
+ d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
+ d->flags &= ~KHUI_HTWND_FOCUS;
- if(d->active_link >= 0) {
- SetCursor(d->hc_hand);
- return TRUE;
- }
- }
- break;
+ InvalidateRect(hwnd, NULL, TRUE);
+ }
+ break;
+
+ case WM_LBUTTONDOWN:
+ {
+ khui_htwnd_data * d;
- case WM_SETFOCUS:
- {
- khui_htwnd_data * d;
+ d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
+ d->md_link = d->active_link;
- d->flags |= KHUI_HTWND_FOCUS;
+ SetCapture(hwnd);
+ }
+ break;
+
+ case WM_LBUTTONUP:
+ {
+ khui_htwnd_data * d;
- InvalidateRect(hwnd, NULL, TRUE);
+ d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
+
+ if(d->md_link == d->active_link && d->md_link >= 0) {
+ /* clicked */
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(d->id, BN_CLICKED), (LPARAM) d->links[d->md_link]);
}
- break;
- case WM_KILLFOCUS:
- {
- khui_htwnd_data * d;
+ ReleaseCapture();
+ }
+ break;
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
+ case WM_HSCROLL:
+ {
+ khui_htwnd_data * d;
+ int old_pos;
+ int new_pos;
+ int ext;
+ SCROLLINFO si;
+ RECT r;
+
+ d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
+
+ old_pos = new_pos = d->scroll_left;
+ ext = d->ext_width;
+
+ switch(HIWORD(wParam)) {
+ case SB_THUMBTRACK:
+ case SB_THUMBPOSITION:
+ ZeroMemory(&si, sizeof(si));
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_TRACKPOS;
+ GetScrollInfo(hwnd, SB_HORZ, &si);
+ new_pos = si.nTrackPos;
+ break;
- d->flags &= ~KHUI_HTWND_FOCUS;
+ case SB_LINELEFT:
+ new_pos -= ext / 12; /* arbitrary unit */
+ break;
- InvalidateRect(hwnd, NULL, TRUE);
+ case SB_LINERIGHT:
+ new_pos += ext / 12; /* arbitrary unit */
+ break;
+
+ case SB_PAGELEFT:
+ GetClientRect(hwnd, &r);
+ new_pos -= r.right - r.left;
+ break;
+
+ case SB_PAGERIGHT:
+ GetClientRect(hwnd, &r);
+ new_pos += r.right - r.left;
+ break;
}
- break;
- case WM_LBUTTONDOWN:
- {
- khui_htwnd_data * d;
+ if (new_pos == old_pos)
+ break;
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
+ GetClientRect(hwnd, &r);
- d->md_link = d->active_link;
+#if 0
+ if (new_pos > ext - (r.right - r.left))
+ new_pos = ext - (r.right - r.left);
+#endif
+ if (new_pos > ext)
+ new_pos = ext;
- SetCapture(hwnd);
- }
- break;
+ if (new_pos < 0)
+ new_pos = 0;
- case WM_LBUTTONUP:
- {
- khui_htwnd_data * d;
+ if (new_pos == old_pos)
+ break;
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
+ ZeroMemory(&si, sizeof(si));
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_POS;
+ si.nPos = new_pos;
+ SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
+ /* note that Windows sometimes adjusts the position after
+ setting it with SetScrollInfo. We have to look it up
+ again to see what value it ended up at. */
+ GetScrollInfo(hwnd, SB_HORZ, &si);
+ new_pos = si.nPos;
+
+ if (new_pos == old_pos)
+ break;
- if(d->md_link == d->active_link && d->md_link >= 0) {
- /* clicked */
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(d->id, BN_CLICKED), (LPARAM) d->links[d->md_link]);
- }
+ d->scroll_left = new_pos;
- ReleaseCapture();
- }
- break;
+ ScrollWindow(hwnd, old_pos - new_pos, 0, NULL, NULL);
- case WM_MOUSEMOVE:
- {
- khui_htwnd_data * d;
- int i;
- POINT p;
- int nl;
+ return 0;
+ }
+ break;
- p.x = GET_X_LPARAM(lParam);
- p.y = GET_Y_LPARAM(lParam);
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
+ case WM_MOUSEMOVE:
+ {
+ khui_htwnd_data * d;
+ int i;
+ POINT p;
+ int nl;
+
+ d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
+ p.x = GET_X_LPARAM(lParam) + d->scroll_left;
+ p.y = GET_Y_LPARAM(lParam) + d->scroll_top;
- for(i=0; i<d->n_links; i++) {
- if(d->links && d->links[i] && PtInRect(&(d->links[i]->r), p))
- break;
- }
+ for(i=0; i<d->n_links; i++) {
+ if(d->links && d->links[i] && PtInRect(&(d->links[i]->r), p))
+ break;
+ }
- if(i == d->n_links)
- nl = -1;
- else
- nl = i;
+ if(i == d->n_links)
+ nl = -1;
+ else
+ nl = i;
- if(d->active_link != nl) {
- if(d->active_link >= 0) {
- if(d->flags & KHUI_HTWND_TRANSPARENT)
+ if(d->active_link != nl) {
+ if(d->active_link >= 0) {
+ if(d->flags & KHUI_HTWND_TRANSPARENT)
{
HWND parent = GetParent(hwnd);
if(parent) {
InvalidateRect(parent, NULL, TRUE);
}
}
- /* although we are invalidating the rect before setting active_link,
- WM_PAINT will not be issued until wndproc returns */
- InvalidateRect(hwnd, &(d->links[d->active_link]->r), TRUE);
- }
- d->active_link = nl;
- if(d->active_link >= 0) {
- /* although we are invalidating the rect before setting active_link,
- WM_PAINT will not be issued until wndproc returns */
- if(d->flags & KHUI_HTWND_TRANSPARENT)
+ /* although we are invalidating the rect before setting active_link,
+ WM_PAINT will not be issued until wndproc returns */
+ InvalidateRect(hwnd, &(d->links[d->active_link]->r), TRUE);
+ }
+ d->active_link = nl;
+ if(d->active_link >= 0) {
+ /* although we are invalidating the rect before setting active_link,
+ WM_PAINT will not be issued until wndproc returns */
+ if(d->flags & KHUI_HTWND_TRANSPARENT)
{
HWND parent = GetParent(hwnd);
if(parent) {
InvalidateRect(parent, NULL, TRUE);
}
}
- InvalidateRect(hwnd, &(d->links[d->active_link]->r), TRUE);
- }
+ InvalidateRect(hwnd, &(d->links[d->active_link]->r), TRUE);
}
}
- break;
+ }
+ break;
}
return DefWindowProc(hwnd, uMsg,wParam,lParam);
diff --git a/src/windows/identity/ui/htwnd.h b/src/windows/identity/ui/htwnd.h
index e83dbb684..2ca8c261b 100644
--- a/src/windows/identity/ui/htwnd.h
+++ b/src/windows/identity/ui/htwnd.h
@@ -40,6 +40,8 @@ We currently support the following tags:
#define KHUI_HTWND_TRANSPARENT 1
#define KHUI_HTWND_CLIENTEDGE 2
+#define KHUI_HTWND_HSCROLL 4
+#define KHUI_HTWND_VSCROLL 8
#define KHUI_HTWND_FOCUS 2048
#define KHUI_HTWND_CLASS L"KhmHtWnd"
diff --git a/src/windows/identity/ui/newcredwnd.c b/src/windows/identity/ui/newcredwnd.c
index 56c79294b..e263f7c87 100644
--- a/src/windows/identity/ui/newcredwnd.c
+++ b/src/windows/identity/ui/newcredwnd.c
@@ -967,7 +967,8 @@ nc_handle_wm_command(HWND hwnd,
l->param_len < ARRAYLENGTH(sparam) &&
l->param_len > 0) {
- wcsncpy(sparam, l->param, l->param_len);
+ StringCchCopyN(sparam, ARRAYLENGTH(sparam),
+ l->param, l->param_len);
sparam[l->param_len] = L'\0';
} else {
@@ -1006,7 +1007,7 @@ nc_handle_wm_command(HWND hwnd,
}
/* if it was for us, then we need to process the message */
- if(!wcsicmp(sid, CTLINKID_SWITCH_PANEL)) {
+ if(!_wcsicmp(sid, CTLINKID_SWITCH_PANEL)) {
khm_int32 credtype;
khui_new_creds_by_type * t;
@@ -1021,10 +1022,10 @@ nc_handle_wm_command(HWND hwnd,
WMNC_DIALOG_SWITCH_PANEL),
0);
}
- } else if (!wcsicmp(sid, L"NotDef")) {
+ } else if (!_wcsicmp(sid, L"NotDef")) {
d->nc->set_default = FALSE;
nc_update_credtext(d);
- } else if (!wcsicmp(sid, L"MakeDef")) {
+ } else if (!_wcsicmp(sid, L"MakeDef")) {
d->nc->set_default = TRUE;
nc_update_credtext(d);
}
diff --git a/src/windows/identity/uilib/action.c b/src/windows/identity/uilib/action.c
index 29699476b..f96ec5dee 100644
--- a/src/windows/identity/uilib/action.c
+++ b/src/windows/identity/uilib/action.c
@@ -29,6 +29,8 @@
#include<utils.h>
#include<assert.h>
+#include<strsafe.h>
+
khui_action_ref khui_main_menu[] = {
MENU_SUBMENU(KHUI_MENU_FILE),
MENU_SUBMENU(KHUI_MENU_CRED),
diff --git a/src/windows/identity/uilib/alert.c b/src/windows/identity/uilib/alert.c
index 3d06a07e2..96436543a 100644
--- a/src/windows/identity/uilib/alert.c
+++ b/src/windows/identity/uilib/alert.c
@@ -28,6 +28,8 @@
#include<utils.h>
#include<assert.h>
+#include<strsafe.h>
+
/***********************************************************************
Alerter
***********************************************************************/
diff --git a/src/windows/identity/uilib/configui.c b/src/windows/identity/uilib/configui.c
index 9aa88cd28..79e570820 100644
--- a/src/windows/identity/uilib/configui.c
+++ b/src/windows/identity/uilib/configui.c
@@ -30,6 +30,8 @@
#include<utils.h>
#include<assert.h>
+#include<strsafe.h>
+
khm_int32 cfgui_node_serial;
LONG init_once = 0;
CRITICAL_SECTION cs_cfgui;
diff --git a/src/windows/identity/uilib/creddlg.c b/src/windows/identity/uilib/creddlg.c
index 154ed18eb..458218d90 100644
--- a/src/windows/identity/uilib/creddlg.c
+++ b/src/windows/identity/uilib/creddlg.c
@@ -28,6 +28,8 @@
#include<utils.h>
#include<assert.h>
+#include<strsafe.h>
+
#define CW_ALLOC_INCR 8
static void cw_free_prompts(khui_new_creds * c);
diff --git a/src/windows/identity/uilib/khnewcred.h b/src/windows/identity/uilib/khnewcred.h
index 45df19779..e561eb108 100644
--- a/src/windows/identity/uilib/khnewcred.h
+++ b/src/windows/identity/uilib/khnewcred.h
@@ -415,24 +415,50 @@ typedef struct tag_khui_new_creds {
#define KHUI_MAXCB_PNAME (KHUI_MAXCCH_PNAME * sizeof(wchar_t))
/*! \brief A descriptor of a panel in the new credentials acquisition tab
+
+ When processing certain credentials messages such as
+ ::KMSG_CRED_PASSWORD, ::KMSG_CRED_NEW_CREDS,
+ ::KMSG_CRED_RENEW_CREDS, a pointer to a ::khui_new_creds structure
+ will be passed in to the message handler. If the handler of the
+ message needs to add one or more credentials types as participants
+ of the operation, the handler will need to call khui_cw_add_type()
+ and specify a ::khui_new_creds_by_type structure.
+
+ Note that the memory address passed in to the call to
+ khui_cw_add_type() will not be copied. Therefore, the block of
+ memory should remain as-is for the lifetime of the
+ ::khui_new_creds structure or until it is removed with a call to
+ khui_cw_del_type().
+
+ Some of the credentials messages that require specifying a
+ ::khui_new_creds_by_type structure require providing a
+ user-interface. In these cases, the fields marked for providing a
+ UI may be required to hold valid values. If the message does not
+ require providing a UI, these fields will be ignored.
*/
typedef struct tag_khui_new_creds_by_type {
khui_new_creds * nc; /*!< Internal use. Do not set */
khm_int32 flags; /*!< Internal use. Do not set */
khm_int32 type; /*!< The identifier of the credentials
- type */
+ type. This is a credentials type
+ identifier allocated with a call to
+ kcdb_credtype_register(). */
khm_int32 type_deps[KHUI_MAX_TYPE_DEPS];
/*!< credentials types that this
credential type depends on. Each
element defines a credentials type
identifier that this type depends
- on for this operation. */
+ on for this operation. The number
+ of valid values in this array
+ should be specified in the \a
+ n_type_deps field. */
khm_size n_type_deps; /*!< Number of dependencies listed
above. Should be between 0 and
- ::KHUI_MAX_TYPE_DEPS */
+ ::KHUI_MAX_TYPE_DEPS. Specify 0 if
+ there are no dependencies. */
khm_size ordinal; /*!< The requested ordinal. The UI
would attempt to place this panel at
@@ -446,29 +472,49 @@ typedef struct tag_khui_new_creds_by_type {
wchar_t *name; /*!< Name of the panel (localized,
optional). If NULL, the localized
name of the credentials type is
- used. */
+ used. Only used if providing a
+ user-interface. */
- HICON icon; /*!< Icon for the panel (optional) */
+ HICON icon; /*!< Icon for the panel (optional).
+ Only used if providing a
+ user-interface. */
wchar_t *tooltip; /*!< Tooltip for the panel (localized,
optional). If NULL, no tooltip will
- be assigned for the panel */
+ be assigned for the panel. Only
+ used if providing a
+ user-interface. */
HMODULE h_module; /*!< Handle to the module containing
- the dialog resource */
-
- LPWSTR dlg_template; /*!< The dialog resource */
- DLGPROC dlg_proc; /*!< The dialog procedure */
+ the dialog resource. Only used if
+ providing a user-interface. */
+
+ LPWSTR dlg_template; /*!< The dialog resource. Only used
+ if providing a user-interface. */
+ DLGPROC dlg_proc; /*!< The dialog procedure. Only used
+ if providing a user-interface. */
+
+ HWND hwnd_panel; /*!< The dialog window. Once the
+ dialog panel is created, a handle to
+ the panel will be assigned here.
+ Note that the handle is assigned
+ after a successful call to
+ CreateDialogParam and hence would
+ not be available when handling the
+ WM_INITDIALOG message from the
+ dialog procedure. Only used of
+ providing a user-interface. */
- HWND hwnd_panel; /*!< The dialog window */
HWND hwnd_tc; /*!< Internal use. Do not set */
wchar_t *credtext; /*!< A brief description of the
current state of this cred
- type. (localized, optional) */
+ type. (localized, optional). Only
+ used if providing a
+ user-interface. */
LPARAM aux; /*!< auxilliary field. For use by the
- credential provider */
+ plug-in. */
} khui_new_creds_by_type;
/*!\name Flags for khui_new_creds_by_type
@@ -652,6 +698,22 @@ khui_cw_unlock_nc(khui_new_creds * c);
See the description of ::khui_new_cred_panel for information on
how to populate it to describe a credentials type panel.
+ Note that the structure pointed to by \a t is added by reference.
+ The memory pointed to by \a t is not copied. Hence, the block of
+ memory and any other blocks pointed to by the
+ ::khui_new_creds_by_type structure located there should remain
+ intact for the lifetime of the ::khui_new_creds structure pointed
+ to by \a c or until the credentials type panel is removed from the
+ ::khui_new_creds structure with a call to khui_cw_del_type().
+
+ Generally, a plug-in that calls this function should allocate a
+ block of memory to contain the ::khui_new_creds_by_type structure,
+ fill it in and then pass in the address in a call to
+ khui_cw_add_type() while handling a ::KMSG_CRED_PASSWORD,
+ ::KMSG_CRED_NEW_CREDS or ::KMSG_CRED_RENEW_CREDS message. Then
+ the plug-in should remove the reference with a call to
+ khui_cw_del_type() while processing ::KMSG_CRED_END.
+
\see khui_cw_del_type()
\see \ref cred_acq_panel_spec
\see ::khui_new_cred_panel
diff --git a/src/windows/identity/util/perfstat.c b/src/windows/identity/util/perfstat.c
index 6cf8ae44a..c9996b31c 100644
--- a/src/windows/identity/util/perfstat.c
+++ b/src/windows/identity/util/perfstat.c
@@ -247,9 +247,14 @@ perf_dump(char * file) {
perf_once();
EnterCriticalSection(&cs_alloc);
+#if _MSC_VER >= 1400
+ if (fopen_s(&f, file, "w"))
+ return;
+#else
f = fopen(file, "w");
if (!f)
- return;
+ return;
+#endif
fprintf(f, "Leaked allocations list ....\n");
fprintf(f, "File\tLine\tThread\tSize\n");