Skip to content

Commit

Permalink
Remove password log message (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrytfleung authored May 4, 2021
1 parent e39f09d commit aaf7fa9
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/odfesqlodbc/odbcapi30w.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ RETCODE SQL_API SQLSetDescFieldW(SQLHDESC DescriptorHandle,
uval = ucs2_to_utf8(
Value,
BufferLength > 0 ? BufferLength / WCLEN : BufferLength,
&vallen, FALSE);
&vallen, FALSE, TRUE);
val_alloced = TRUE;
break;
default:
Expand Down
93 changes: 47 additions & 46 deletions src/odfesqlodbc/odbcapiw.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ RETCODE SQL_API SQLColumnsW(HSTMT StatementHandle, SQLWCHAR *CatalogName,
conn = SC_get_conn(stmt);
ci = &(conn->connInfo);
lower_id = DEFAULT_LOWERCASEIDENTIFIER;
ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id);
scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id);
tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id);
clName = ucs2_to_utf8(ColumnName, NameLength4, &nmlen4, lower_id);
ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id, TRUE);
scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id, TRUE);
tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id, TRUE);
clName = ucs2_to_utf8(ColumnName, NameLength4, &nmlen4, lower_id, TRUE);
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
if (stmt->options.metadata_id)
Expand Down Expand Up @@ -88,9 +88,9 @@ RETCODE SQL_API SQLConnectW(HDBC ConnectionHandle, SQLWCHAR *ServerName,
ENTER_CONN_CS(conn);
CC_clear_error(conn);
CC_set_in_unicode_driver(conn);
svName = ucs2_to_utf8(ServerName, NameLength1, &nmlen1, FALSE);
usName = ucs2_to_utf8(UserName, NameLength2, &nmlen2, FALSE);
auth = ucs2_to_utf8(Authentication, NameLength3, &nmlen3, FALSE);
svName = ucs2_to_utf8(ServerName, NameLength1, &nmlen1, FALSE, TRUE);
usName = ucs2_to_utf8(UserName, NameLength2, &nmlen2, FALSE, TRUE);
auth = ucs2_to_utf8(Authentication, NameLength3, &nmlen3, FALSE, FALSE);
ret =
API_Connect(ConnectionHandle, (SQLCHAR *)svName, (SQLSMALLINT)nmlen1,
(SQLCHAR *)usName, (SQLSMALLINT)nmlen2, (SQLCHAR *)auth,
Expand Down Expand Up @@ -123,7 +123,7 @@ RETCODE SQL_API SQLDriverConnectW(HDBC hdbc, HWND hwnd, SQLWCHAR *szConnStrIn,
ENTER_CONN_CS(conn);
CC_clear_error(conn);
CC_set_in_unicode_driver(conn);
szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen, FALSE);
szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen, FALSE, FALSE);
maxlen = cbConnStrOutMax;
pCSO = NULL;
olen = 0;
Expand Down Expand Up @@ -187,7 +187,7 @@ RETCODE SQL_API SQLBrowseConnectW(HDBC hdbc, SQLWCHAR *szConnStrIn,
ENTER_CONN_CS(conn);
CC_clear_error(conn);
CC_set_in_unicode_driver(conn);
szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen, FALSE);
szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen, FALSE, FALSE);
obuflen = cbConnStrOutMax + 1;
szOut = malloc(obuflen);
if (szOut)
Expand Down Expand Up @@ -296,7 +296,7 @@ RETCODE SQL_API SQLExecDirectW(HSTMT StatementHandle, SQLWCHAR *StatementText,

// Get query string
SQLLEN slen = 0;
char *stxt = ucs2_to_utf8(StatementText, TextLength, &slen, FALSE);
char *stxt = ucs2_to_utf8(StatementText, TextLength, &slen, FALSE, TRUE);

// Enter critical
ENTER_STMT_CS(stmt);
Expand Down Expand Up @@ -396,7 +396,7 @@ RETCODE SQL_API SQLPrepareW(HSTMT StatementHandle, SQLWCHAR *StatementText,
return SQL_ERROR;

SQLLEN slen;
char *stxt = ucs2_to_utf8(StatementText, TextLength, &slen, FALSE);
char *stxt = ucs2_to_utf8(StatementText, TextLength, &slen, FALSE, TRUE);

// Enter critical
ENTER_STMT_CS(stmt);
Expand Down Expand Up @@ -427,7 +427,7 @@ RETCODE SQL_API SQLSetCursorNameW(HSTMT StatementHandle, SQLWCHAR *CursorName,
SQLLEN nlen;

MYLOG(LOG_TRACE, "entering\n");
crName = ucs2_to_utf8(CursorName, NameLength, &nlen, FALSE);
crName = ucs2_to_utf8(CursorName, NameLength, &nlen, FALSE, TRUE);
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
ret = ESAPI_SetCursorName(StatementHandle, (SQLCHAR *)crName,
Expand Down Expand Up @@ -457,9 +457,9 @@ RETCODE SQL_API SQLSpecialColumnsW(

conn = SC_get_conn(stmt);
lower_id = DEFAULT_LOWERCASEIDENTIFIER;
ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id);
scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id);
tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id);
ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id, TRUE);
scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id, TRUE);
tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id, TRUE);
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
if (SC_opencheck(stmt, func))
Expand Down Expand Up @@ -498,9 +498,9 @@ RETCODE SQL_API SQLStatisticsW(HSTMT StatementHandle, SQLWCHAR *CatalogName,

conn = SC_get_conn(stmt);
lower_id = DEFAULT_LOWERCASEIDENTIFIER;
ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id);
scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id);
tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id);
ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id, TRUE);
scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id, TRUE);
tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id, TRUE);
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
if (SC_opencheck(stmt, func))
Expand Down Expand Up @@ -540,10 +540,10 @@ RETCODE SQL_API SQLTablesW(HSTMT StatementHandle, SQLWCHAR *CatalogName,

conn = SC_get_conn(stmt);
lower_id = DEFAULT_LOWERCASEIDENTIFIER;
ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id);
scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id);
tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id);
tbType = ucs2_to_utf8(TableType, NameLength4, &nmlen4, FALSE);
ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id, TRUE);
scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id, TRUE);
tbName = ucs2_to_utf8(TableName, NameLength3, &nmlen3, lower_id, TRUE);
tbType = ucs2_to_utf8(TableType, NameLength4, &nmlen4, FALSE, TRUE);
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
if (stmt->options.metadata_id)
Expand Down Expand Up @@ -586,10 +586,11 @@ RETCODE SQL_API SQLColumnPrivilegesW(

conn = SC_get_conn(stmt);
lower_id = DEFAULT_LOWERCASEIDENTIFIER;
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id);
tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3, lower_id);
clName = ucs2_to_utf8(szColumnName, cbColumnName, &nmlen4, lower_id);
ctName =
ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id, TRUE);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id, TRUE);
tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3, lower_id, TRUE);
clName = ucs2_to_utf8(szColumnName, cbColumnName, &nmlen4, lower_id, TRUE);
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
if (stmt->options.metadata_id)
Expand Down Expand Up @@ -634,13 +635,13 @@ RETCODE SQL_API SQLForeignKeysW(

conn = SC_get_conn(stmt);
lower_id = DEFAULT_LOWERCASEIDENTIFIER;
ctName = ucs2_to_utf8(szPkCatalogName, cbPkCatalogName, &nmlen1, lower_id);
scName = ucs2_to_utf8(szPkSchemaName, cbPkSchemaName, &nmlen2, lower_id);
tbName = ucs2_to_utf8(szPkTableName, cbPkTableName, &nmlen3, lower_id);
ctName = ucs2_to_utf8(szPkCatalogName, cbPkCatalogName, &nmlen1, lower_id, TRUE);
scName = ucs2_to_utf8(szPkSchemaName, cbPkSchemaName, &nmlen2, lower_id, TRUE);
tbName = ucs2_to_utf8(szPkTableName, cbPkTableName, &nmlen3, lower_id, TRUE);
fkctName =
ucs2_to_utf8(szFkCatalogName, cbFkCatalogName, &nmlen4, lower_id);
fkscName = ucs2_to_utf8(szFkSchemaName, cbFkSchemaName, &nmlen5, lower_id);
fktbName = ucs2_to_utf8(szFkTableName, cbFkTableName, &nmlen6, lower_id);
ucs2_to_utf8(szFkCatalogName, cbFkCatalogName, &nmlen4, lower_id, TRUE);
fkscName = ucs2_to_utf8(szFkSchemaName, cbFkSchemaName, &nmlen5, lower_id, TRUE);
fktbName = ucs2_to_utf8(szFkTableName, cbFkTableName, &nmlen6, lower_id, TRUE);
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
if (SC_opencheck(stmt, func))
Expand Down Expand Up @@ -681,7 +682,7 @@ RETCODE SQL_API SQLNativeSqlW(HDBC hdbc, SQLWCHAR *szSqlStrIn,
ENTER_CONN_CS(conn);
CC_clear_error(conn);
CC_set_in_unicode_driver(conn);
szIn = ucs2_to_utf8(szSqlStrIn, cbSqlStrIn, &slen, FALSE);
szIn = ucs2_to_utf8(szSqlStrIn, cbSqlStrIn, &slen, FALSE, TRUE);
buflen = 3 * cbSqlStrMax;
if (buflen > 0)
szOutt = malloc(buflen);
Expand Down Expand Up @@ -736,9 +737,9 @@ RETCODE SQL_API SQLPrimaryKeysW(HSTMT hstmt, SQLWCHAR *szCatalogName,

conn = SC_get_conn(stmt);
lower_id = DEFAULT_LOWERCASEIDENTIFIER;
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id);
tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3, lower_id);
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id, TRUE);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id, TRUE);
tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3, lower_id, TRUE);
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
if (SC_opencheck(stmt, func))
Expand Down Expand Up @@ -773,10 +774,10 @@ RETCODE SQL_API SQLProcedureColumnsW(
MYLOG(LOG_TRACE, "entering\n");
conn = SC_get_conn(stmt);
lower_id = DEFAULT_LOWERCASEIDENTIFIER;
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id);
prName = ucs2_to_utf8(szProcName, cbProcName, &nmlen3, lower_id);
clName = ucs2_to_utf8(szColumnName, cbColumnName, &nmlen4, lower_id);
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id, TRUE);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id, TRUE);
prName = ucs2_to_utf8(szProcName, cbProcName, &nmlen3, lower_id, TRUE);
clName = ucs2_to_utf8(szColumnName, cbColumnName, &nmlen4, lower_id, TRUE);
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
if (stmt->options.metadata_id)
Expand Down Expand Up @@ -819,9 +820,9 @@ RETCODE SQL_API SQLProceduresW(HSTMT hstmt, SQLWCHAR *szCatalogName,

conn = SC_get_conn(stmt);
lower_id = DEFAULT_LOWERCASEIDENTIFIER;
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id);
prName = ucs2_to_utf8(szProcName, cbProcName, &nmlen3, lower_id);
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id, TRUE);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id, TRUE);
prName = ucs2_to_utf8(szProcName, cbProcName, &nmlen3, lower_id, TRUE);
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
if (stmt->options.metadata_id)
Expand Down Expand Up @@ -863,9 +864,9 @@ RETCODE SQL_API SQLTablePrivilegesW(HSTMT hstmt, SQLWCHAR *szCatalogName,

conn = SC_get_conn(stmt);
lower_id = DEFAULT_LOWERCASEIDENTIFIER;
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id);
tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3, lower_id);
ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id, TRUE);
scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id, TRUE);
tbName = ucs2_to_utf8(szTableName, cbTableName, &nmlen3, lower_id, TRUE);
ENTER_STMT_CS((StatementClass *)hstmt);
SC_clear_error(stmt);
if (stmt->options.metadata_id)
Expand Down
2 changes: 1 addition & 1 deletion src/odfesqlodbc/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ RETCODE SQL_API ESAPI_SetConnectOption(HDBC hdbc, SQLUSMALLINT fOption,
#ifdef UNICODE_SUPPORT
if (CC_is_in_unicode_driver(conn)) {
char *asPara =
ucs2_to_utf8((SQLWCHAR *)vParam, SQL_NTS, NULL, FALSE);
ucs2_to_utf8((SQLWCHAR *)vParam, SQL_NTS, NULL, FALSE, TRUE);
cmp = strcmp(asPara, "Microsoft Jet");
free(asPara);
} else
Expand Down
1 change: 0 additions & 1 deletion src/odfesqlodbc/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ void test_connection(HANDLE hwnd, ConnInfo *ci, BOOL withDTC) {
dsn_1st = ci->dsn[0];
ci->dsn[0] = '\0';
makeConnectString(out_conn, ci, sizeof(out_conn));
MYLOG(LOG_DEBUG, "conn_string=%s\n", out_conn);
#ifdef UNICODE_SUPPORT
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, out_conn, -1, wout_conn,
sizeof(wout_conn) / sizeof(wout_conn[0]));
Expand Down
2 changes: 1 addition & 1 deletion src/odfesqlodbc/unicode_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define WCLEN sizeof(SQLWCHAR)
enum { CONVTYPE_UNKNOWN, WCSTYPE_UTF16_LE, WCSTYPE_UTF32_LE, C16TYPE_UTF16_LE };
char *ucs2_to_utf8(const SQLWCHAR *ucs2str, SQLLEN ilen, SQLLEN *olen,
BOOL tolower);
BOOL tolower, BOOL loggable);
SQLULEN utf8_to_ucs2_lf(const char *utf8str, SQLLEN ilen, BOOL lfconv,
SQLWCHAR *ucs2str, SQLULEN buflen, BOOL errcheck);
int get_convtype(void);
Expand Down
12 changes: 8 additions & 4 deletions src/odfesqlodbc/win_unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ SQLULEN ucs2strlen(const SQLWCHAR *ucs2str) {
return len;
}
char *ucs2_to_utf8(const SQLWCHAR *ucs2str, SQLLEN ilen, SQLLEN *olen,
BOOL lower_identifier) {
BOOL lower_identifier, BOOL loggable) {
char *utf8str;
int len = 0;
MYLOG(LOG_DEBUG, "%p ilen=" FORMAT_LEN " ", ucs2str, ilen);
if (loggable) {
MYLOG(LOG_DEBUG, "%p ilen=" FORMAT_LEN " ", ucs2str, ilen);
}

if (!ucs2str) {
if (olen)
Expand Down Expand Up @@ -204,7 +206,9 @@ char *ucs2_to_utf8(const SQLWCHAR *ucs2str, SQLLEN ilen, SQLLEN *olen,
if (olen)
*olen = len;
}
MYPRINTF(0, " olen=%d utf8str=%s\n", len, utf8str ? utf8str : "");
if (loggable) {
MYPRINTF(0, " olen=%d utf8str=%s\n", len, utf8str ? utf8str : "");
}
return utf8str;
}

Expand Down Expand Up @@ -687,7 +691,7 @@ static char *wcs_to_utf8(const wchar_t *wcsstr, SQLLEN ilen, SQLLEN *olen,
switch (get_convtype()) {
case WCSTYPE_UTF16_LE:
return ucs2_to_utf8((const SQLWCHAR *)wcsstr, ilen, olen,
lower_identifier);
lower_identifier, TRUE);
case WCSTYPE_UTF32_LE:
return ucs4_to_utf8((const UInt4 *)wcsstr, ilen, olen,
lower_identifier);
Expand Down

0 comments on commit aaf7fa9

Please sign in to comment.