From commits-return-8775-archive-asf-public=cust-asf.ponee.io@trafodion.apache.org Wed Dec 5 00:00:49 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 4042D180652 for ; Wed, 5 Dec 2018 00:00:49 +0100 (CET) Received: (qmail 30525 invoked by uid 500); 4 Dec 2018 23:00:48 -0000 Mailing-List: contact commits-help@trafodion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: commits@trafodion.apache.org Delivered-To: mailing list commits@trafodion.apache.org Received: (qmail 30516 invoked by uid 99); 4 Dec 2018 23:00:48 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2018 23:00:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 49964DFA5C; Tue, 4 Dec 2018 23:00:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dbirdsall@apache.org To: commits@trafodion.apache.org Date: Tue, 04 Dec 2018 23:00:48 -0000 Message-Id: <751d47ce79ae4cf7bdd80496d1a4b474@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] trafodion git commit: ODBC can not connect to server when the local language is gbk Repository: trafodion Updated Branches: refs/heads/master 3ce71cae6 -> f66c38528 ODBC can not connect to server when the local language is gbk Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/c914a3e0 Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/c914a3e0 Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/c914a3e0 Branch: refs/heads/master Commit: c914a3e09ba2db36078c871e5805c54fa2e59404 Parents: f04ffee Author: Weixin-Xu <1013438133@qq.com> Authored: Wed Nov 28 11:08:47 2018 +0800 Committer: Weixin-Xu <1013438133@qq.com> Committed: Wed Nov 28 11:08:47 2018 +0800 ---------------------------------------------------------------------- win-odbc64/odbcclient/drvr35/charsetconv.cpp | 2 +- win-odbc64/odbcclient/drvr35/charsetconv.h | 2 +- .../security_dll/native/source/secpwd.cpp | 25 ++++++++++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/c914a3e0/win-odbc64/odbcclient/drvr35/charsetconv.cpp ---------------------------------------------------------------------- diff --git a/win-odbc64/odbcclient/drvr35/charsetconv.cpp b/win-odbc64/odbcclient/drvr35/charsetconv.cpp index f53cc81..2b211b7 100644 --- a/win-odbc64/odbcclient/drvr35/charsetconv.cpp +++ b/win-odbc64/odbcclient/drvr35/charsetconv.cpp @@ -199,7 +199,7 @@ SQLRETURN UTF8ToWChar(char *st, int stlen, wchar_t *wst, int wstlen, int *transl // The fuction translates a string between UTF-8 and Client Locale. // If the first argument is TRUE, the function converts the given string from UTF-8 to Locale. // If the first argument is FALSE, the function converts the given string from Locale to UTF-8 -SQLRETURN TranslateUTF8(bool forward, char *inst, int inlen, char *outst, int outlen, int *translen, char *errorMsg) +SQLRETURN TranslateUTF8(bool forward, const char *inst, int inlen, char *outst, int outlen, int *translen, char *errorMsg) { SQLRETURN rc = SQL_SUCCESS; int len; http://git-wip-us.apache.org/repos/asf/trafodion/blob/c914a3e0/win-odbc64/odbcclient/drvr35/charsetconv.h ---------------------------------------------------------------------- diff --git a/win-odbc64/odbcclient/drvr35/charsetconv.h b/win-odbc64/odbcclient/drvr35/charsetconv.h index 6216a69..5c28304 100644 --- a/win-odbc64/odbcclient/drvr35/charsetconv.h +++ b/win-odbc64/odbcclient/drvr35/charsetconv.h @@ -31,7 +31,7 @@ SQLRETURN UTF8ToWChar(char *st, int stlen, wchar_t *wst, int wstlen, int *trans // If the first argument is TRUE, the function converts the given string from UTF-8 to Locale. // If the first argument is FALSE, the function converts the given string from Locale to UTF-8 -SQLRETURN TranslateUTF8(bool forward, char *inst, int inlen, char *outst, int outlen, int *translen, char *errorMsg); +SQLRETURN TranslateUTF8(bool forward, const char *inst, int inlen, char *outst, int outlen, int *translen, char *errorMsg); SQLRETURN WCharToLocale(wchar_t *wst, int wstlen, char *st, int stlen, int *translen, char* error = NULL, char *replacementChar = NULL); SQLRETURN LocaleToWChar(char *st, int stlen, wchar_t *wst, int wstlen, int *translen, char* error = NULL); http://git-wip-us.apache.org/repos/asf/trafodion/blob/c914a3e0/win-odbc64/security_dll/native/source/secpwd.cpp ---------------------------------------------------------------------- diff --git a/win-odbc64/security_dll/native/source/secpwd.cpp b/win-odbc64/security_dll/native/source/secpwd.cpp index 3af666e..c2bd427 100644 --- a/win-odbc64/security_dll/native/source/secpwd.cpp +++ b/win-odbc64/security_dll/native/source/secpwd.cpp @@ -175,6 +175,10 @@ SecPwd::SecPwd(const char *dir, const char* fileName, { char* dir_from_env = NULL; char certDir[MAX_SQL_IDENTIFIER_LEN + 1]; + char* serverNameGBKToUtf8 = NULL; + LCID lcid = GetSystemDefaultLCID(); + int translen = 0; + char transError[128] = { 0 }; if (serverName == NULL) throw SecurityException (INPUT_PARAMETER_IS_NULL, " - serverName."); @@ -217,8 +221,25 @@ SecPwd::SecPwd(const char *dir, const char* fileName, if(stat(certDir,&st) != 0) throw SecurityException(DIR_NOTFOUND, (char *)certDir); - certFile = buildName(certDir, fileName, serverName, CER); - activeCertFile = buildName(certDir, activeFileName, serverName, ACTIVE_CER); + if (lcid == 0x804) // if local charset is not utf8 + { + serverNameGBKToUtf8 = (char *)malloc(MAX_SQL_IDENTIFIER_LEN + 1); + if (TranslateUTF8(TRUE, serverName, MAX_SQL_IDENTIFIER_LEN, + serverNameGBKToUtf8, MAX_SQL_IDENTIFIER_LEN, &translen, transError) != SQL_SUCCESS) + { + delete serverNameGBKToUtf8; + throw SecurityException(INPUT_PARAMETER_IS_NULL, " - serverName."); + } + certFile = buildName(certDir, fileName, serverNameGBKToUtf8, CER); + activeCertFile = buildName(certDir, activeFileName, serverNameGBKToUtf8, ACTIVE_CER); + + delete serverNameGBKToUtf8; + } + else + { + certFile = buildName(certDir, fileName, serverName, CER); + activeCertFile = buildName(certDir, activeFileName, serverName, ACTIVE_CER); + } // If activeCertFile does not exist and certFile exist, create activeCertFile // by from copying certFile to activeCertFile