]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - windows/wingss.c
first pass
[PuTTY.git] / windows / wingss.c
index 9084c3cfb1c2643c529921ebb2c508cc5b60dfa6..6b4d0f15e0850f522282ae092b9107f6f95c15ab 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "putty.h"
 
+#define SECURITY_WIN32
 #include <security.h>
 
 #include "pgssapi.h"
@@ -18,10 +19,10 @@ const char *const gsslibnames[3] = {
     "Microsoft SSPI SECUR32.DLL",
     "User-specified GSSAPI DLL",
 };
-const struct keyval gsslibkeywords[] = {
-    { "gssapi32", 0 },
-    { "sspi", 1 },
-    { "custom", 2 },
+const struct keyvalwhere gsslibkeywords[] = {
+    { "gssapi32", 0, -1, -1 },
+    { "sspi", 1, -1, -1 },
+    { "custom", 2, -1, -1 },
 };
 
 DECL_WINDOWS_FUNCTION(static, SECURITY_STATUS,
@@ -65,11 +66,12 @@ const char *gsslogmsg = NULL;
 
 static void ssh_sspi_bind_fns(struct ssh_gss_library *lib);
 
-struct ssh_gss_liblist *ssh_gss_setup(const Config *cfg)
+struct ssh_gss_liblist *ssh_gss_setup(Conf *conf)
 {
     HMODULE module;
     HKEY regkey;
     struct ssh_gss_liblist *list = snew(struct ssh_gss_liblist);
+    char *path;
 
     list->libraries = snewn(3, struct ssh_gss_library);
     list->nlibraries = 0;
@@ -81,18 +83,22 @@ struct ssh_gss_liblist *ssh_gss_setup(const Config *cfg)
        == ERROR_SUCCESS) {
        DWORD type, size;
        LONG ret;
-       char *buffer;
-
-       /* Find out the string length */
-        ret = RegQueryValueEx(regkey, "InstallDir", NULL, &type, NULL, &size);
+       wchar_t *buffer;
 
+       /* Find out the string length, in bytes, for a wchar_t */
+        ret = RegQueryValueExW(regkey, L"InstallDir", NULL, &type, NULL, &size);
        if (ret == ERROR_SUCCESS && type == REG_SZ) {
            buffer = snewn(size + 20, char);
-           ret = RegQueryValueEx(regkey, "InstallDir", NULL,
-                                 &type, buffer, &size);
+           ret = RegQueryValueExW(regkey, L"InstallDir", NULL,
+                                  &type, (LPBYTE)buffer, &size);
            if (ret == ERROR_SUCCESS && type == REG_SZ) {
-               strcat(buffer, "\\bin\\gssapi32.dll");
-               module = LoadLibrary(buffer);
+               wcscat(buffer, L"\\bin\\");
+               dll_hijacking_protection_add_path(buffer);
+               /* If 32-bit */
+               module = LoadLibrary("gssapi32.dll");
+               /* elif 64-bit */
+               /* module = LoadLibrary("gssapi64.dll"); */
+
            }
            sfree(buffer);
        }
@@ -148,8 +154,9 @@ struct ssh_gss_liblist *ssh_gss_setup(const Config *cfg)
      * Custom GSSAPI DLL.
      */
     module = NULL;
-    if (cfg->ssh_gss_custom.path[0]) {
-       module = LoadLibrary(cfg->ssh_gss_custom.path);
+    path = conf_get_filename(conf, CONF_ssh_gss_custom)->path;
+    if (*path) {
+       module = LoadLibrary(path);
     }
     if (module) {
        struct ssh_gss_library *lib =
@@ -157,7 +164,7 @@ struct ssh_gss_liblist *ssh_gss_setup(const Config *cfg)
 
        lib->id = 2;
        lib->gsslogmsg = dupprintf("Using GSSAPI from user-specified"
-                                  " library '%s'", cfg->ssh_gss_custom.path);
+                                  " library '%s'", path);
        lib->handle = (void *)module;
 
 #define BIND_GSS_FN(name) \
@@ -352,7 +359,7 @@ static Ssh_gss_stat ssh_sspi_display_status(struct ssh_gss_library *lib,
                                            Ssh_gss_ctx ctx, Ssh_gss_buf *buf)
 {
     winSsh_gss_ctx *winctx = (winSsh_gss_ctx *) ctx;
-    char *msg;
+    const char *msg;
 
     if (winctx == NULL) return SSH_GSS_FAILURE;