https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d34c33223c689806d7a0b…
commit d34c33223c689806d7a0b0c1843b4dd35167cf8d
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Tue Jan 29 13:14:20 2019 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Tue Jan 29 13:14:20 2019 +0100
[ODBCCP32] Sync with Wine Staging 4.0. CORE-15682
---
dll/win32/odbccp32/odbccp32.c | 71 +++++++++++++++++++++++++++++--------------
media/doc/README.WINE | 2 +-
2 files changed, 50 insertions(+), 23 deletions(-)
diff --git a/dll/win32/odbccp32/odbccp32.c b/dll/win32/odbccp32/odbccp32.c
index 862237c677..ae2fe9c35c 100644
--- a/dll/win32/odbccp32/odbccp32.c
+++ b/dll/win32/odbccp32/odbccp32.c
@@ -29,7 +29,11 @@
#include "winbase.h"
#include "winreg.h"
#include "winnls.h"
+#include "sqlext.h"
#include "wine/unicode.h"
+#ifdef __REACTOS__
+#undef TRACE_ON
+#endif
#include "wine/debug.h"
#include "wine/heap.h"
@@ -71,7 +75,7 @@ static const WCHAR odbc_error_invalid_keyword[] =
{'I','n','v','a','l','i','d','
/* Push an error onto the error stack, taking care of ranges etc. */
static void push_error(int code, LPCWSTR msg)
{
- if (num_errors < sizeof error_code/sizeof error_code[0])
+ if (num_errors < ARRAY_SIZE(error_code))
{
error_code[num_errors] = code;
error_msg[num_errors] = msg;
@@ -259,19 +263,25 @@ static HMODULE load_config_driver(const WCHAR *driver)
if ((ret = RegOpenKeyW(hkey, driver, &hkeydriver)) == ERROR_SUCCESS)
{
ret = RegGetValueW(hkeydriver, NULL, reg_driver, RRF_RT_REG_SZ, &type,
NULL, &size);
- if(ret == ERROR_MORE_DATA)
+ if(ret != ERROR_SUCCESS || type != REG_SZ)
{
- filename = HeapAlloc(GetProcessHeap(), 0, size);
- if(!filename)
- {
- RegCloseKey(hkeydriver);
- RegCloseKey(hkey);
- push_error(ODBC_ERROR_OUT_OF_MEM, odbc_error_out_of_mem);
+ RegCloseKey(hkeydriver);
+ RegCloseKey(hkey);
+ push_error(ODBC_ERROR_INVALID_DSN, odbc_error_invalid_dsn);
- return NULL;
- }
- ret = RegGetValueW(hkeydriver, NULL, driver, RRF_RT_REG_SZ, &type,
filename, &size);
+ return NULL;
+ }
+
+ filename = HeapAlloc(GetProcessHeap(), 0, size);
+ if(!filename)
+ {
+ RegCloseKey(hkeydriver);
+ RegCloseKey(hkey);
+ push_error(ODBC_ERROR_OUT_OF_MEM, odbc_error_out_of_mem);
+
+ return NULL;
}
+ ret = RegGetValueW(hkeydriver, NULL, reg_driver, RRF_RT_REG_SZ, &type,
filename, &size);
RegCloseKey(hkeydriver);
}
@@ -572,7 +582,10 @@ BOOL WINAPI SQLGetInstalledDrivers(char *buf, WORD size, WORD
*sizeout)
ret = SQLGetInstalledDriversW(wbuf, size, &written);
if (!ret)
+ {
+ heap_free(wbuf);
return FALSE;
+ }
*sizeout = WideCharToMultiByte(CP_ACP, 0, wbuf, written, NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, wbuf, written, buf, size, NULL, NULL);
@@ -1505,34 +1518,44 @@ BOOL WINAPI SQLSetConfigMode(UWORD wConfigMode)
BOOL WINAPI SQLValidDSNW(LPCWSTR lpszDSN)
{
+ static const WCHAR invalid[] =
{'[',']','{','}','(',')',',',';','?','*','=','!','@','\\',0};
clear_errors();
- FIXME("%s\n", debugstr_w(lpszDSN));
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ TRACE("%s\n", debugstr_w(lpszDSN));
+
+ if(strlenW(lpszDSN) > SQL_MAX_DSN_LENGTH || strpbrkW(lpszDSN, invalid) != NULL)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
}
BOOL WINAPI SQLValidDSN(LPCSTR lpszDSN)
{
+ static const char *invalid = "[]{}(),;?*=!@\\";
clear_errors();
- FIXME("%s\n", debugstr_a(lpszDSN));
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ TRACE("%s\n", debugstr_a(lpszDSN));
+
+ if(strlen(lpszDSN) > SQL_MAX_DSN_LENGTH || strpbrk(lpszDSN, invalid) != NULL)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
}
BOOL WINAPI SQLWriteDSNToIniW(LPCWSTR lpszDSN, LPCWSTR lpszDriver)
{
clear_errors();
FIXME("%s %s\n", debugstr_w(lpszDSN), debugstr_w(lpszDriver));
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ return TRUE;
}
BOOL WINAPI SQLWriteDSNToIni(LPCSTR lpszDSN, LPCSTR lpszDriver)
{
clear_errors();
FIXME("%s %s\n", debugstr_a(lpszDSN), debugstr_a(lpszDriver));
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ return TRUE;
}
BOOL WINAPI SQLWriteFileDSNW(LPCWSTR lpszFileName, LPCWSTR lpszAppName,
@@ -1558,6 +1581,7 @@ BOOL WINAPI SQLWriteFileDSN(LPCSTR lpszFileName, LPCSTR
lpszAppName,
BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry,
LPCWSTR lpszString, LPCWSTR lpszFilename)
{
+ static const WCHAR empty[] = {0};
LONG ret;
HKEY hkey;
@@ -1581,7 +1605,10 @@ BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection,
LPCWSTR lpszEntry
if ((ret = RegCreateKeyW(hkeyfilename, lpszSection, &hkey_section)) ==
ERROR_SUCCESS)
{
- ret = RegSetValueExW(hkey_section, lpszEntry, 0, REG_SZ,
(BYTE*)lpszString, (lstrlenW(lpszString)+1)*sizeof(WCHAR));
+ if(lpszString)
+ ret = RegSetValueExW(hkey_section, lpszEntry, 0, REG_SZ,
(BYTE*)lpszString, (lstrlenW(lpszString)+1)*sizeof(WCHAR));
+ else
+ ret = RegSetValueExW(hkey_section, lpszEntry, 0, REG_SZ,
(BYTE*)empty, sizeof(empty));
RegCloseKey(hkey_section);
}
diff --git a/media/doc/README.WINE b/media/doc/README.WINE
index ebe99bba75..7b4141c99b 100644
--- a/media/doc/README.WINE
+++ b/media/doc/README.WINE
@@ -138,7 +138,7 @@ reactos/dll/win32/npptools # Synced to WineStaging-3.3
reactos/dll/win32/ntdsapi # Synced to WineStaging-3.9
reactos/dll/win32/objsel # Synced to WineStaging-3.3
reactos/dll/win32/odbc32 # Synced to WineStaging-4.0. Depends on port of
Linux ODBC.
-reactos/dll/win32/odbccp32 # Synced to WineStaging-3.9
+reactos/dll/win32/odbccp32 # Synced to WineStaging-4.0
reactos/dll/win32/ole32 # Synced to WineStaging-3.9
reactos/dll/win32/oleacc # Synced to WineStaging-3.3
reactos/dll/win32/oleaut32 # Synced to WineStaging-3.3