]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
first pass 0.68+kerberos-fix
authorAlejandro R. Sedeño <asedeno@mit.edu>
Fri, 24 Feb 2017 03:25:45 +0000 (22:25 -0500)
committerAlejandro R. Sedeño <asedeno@mit.edu>
Fri, 24 Feb 2017 03:50:16 +0000 (22:50 -0500)
windows/wingss.c
windows/winmisc.c
windows/winstuff.h

index 6aaa20cf2c45ccb6956864a2131a3a3fc056fc72..6b4d0f15e0850f522282ae092b9107f6f95c15ab 100644 (file)
@@ -83,18 +83,22 @@ struct ssh_gss_liblist *ssh_gss_setup(Conf *conf)
        == 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, (LPBYTE)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);
        }
index 11e2ca0f7d1353b46db523ca2d66f48b8ba85ad6..8bd4c77f88171fbea6672425a5eabed1817ba4bc 100644 (file)
@@ -176,11 +176,25 @@ void dll_hijacking_protection(void)
     }
 
     if (p_SetDefaultDllDirectories) {
-        /* LOAD_LIBRARY_SEARCH_SYSTEM32 only */
-        p_SetDefaultDllDirectories(0x800);
+        /* LOAD_LIBRARY_SEARCH_SYSTEM32 | LOAD_LIBRARY_SEARCH_USER_DIRS only */
+        p_SetDefaultDllDirectories(0x800|0x400);
     }
 }
 
+void dll_hijacking_protection_add_path(const wchar_t *path)
+{
+    static HMODULE kernel32_module;
+    DECL_WINDOWS_FUNCTION(static, BOOL, AddDllDirectory, (PCWSTR));
+
+    if (!kernel32_module) {
+        kernel32_module = load_system32_dll("kernel32.dll");
+        GET_WINDOWS_FUNCTION(kernel32_module, AddDllDirectory);
+    }
+
+    if (p_AddDllDirectory) {
+        p_AddDllDirectory(path);
+    }
+}
 BOOL init_winver(void)
 {
     ZeroMemory(&osVersion, sizeof(osVersion));
index c1918d4ad2744273786a45d8079c2f7129859292..d7577cf6f982ae2028d65cf79ac4a8b1a8f25b10 100644 (file)
@@ -506,6 +506,7 @@ void show_help(HWND hwnd);
  */
 extern OSVERSIONINFO osVersion;
 void dll_hijacking_protection(void);
+void dll_hijacking_protection_add_path(const wchar_t*);
 BOOL init_winver(void);
 HMODULE load_system32_dll(const char *libname);
 const char *win_strerror(int error);