Skip to content

Commit ce1b574

Browse files
authored
Fix: Replace %ls with %s and use PyUnicode_AsUTF8() in debug log messages (#1052)
Signed-off-by: Earamma K <ek@rocketsoftware.com>
1 parent ee7140a commit ce1b574

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

ibm_db.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,8 +2354,8 @@ static PyObject *_python_ibm_db_connect_helper(PyObject *self, PyObject *args, i
23542354
database, SQL_NTS, NULL, 0, NULL,
23552355
SQL_DRIVER_NOPROMPT);
23562356
Py_END_ALLOW_THREADS;
2357-
snprintf(messageStr, sizeof(messageStr), "SQLDriverConnectW called with parameters: conn_res->hdbc=%p, SQLHWND=NULL, database=%ls, SQL_NTS=%d, NULL, 0, NULL, SQL_DRIVER_NOPROMPT=%d and returned rc=%d",
2358-
(void *)conn_res->hdbc, database, SQL_NTS, SQL_DRIVER_NOPROMPT, rc);
2357+
snprintf(messageStr, sizeof(messageStr), "SQLDriverConnectW called with parameters: conn_res->hdbc=%p, SQLHWND=NULL, database=%s, SQL_NTS=%d, NULL, 0, NULL, SQL_DRIVER_NOPROMPT=%d and returned rc=%d",
2358+
(void *)conn_res->hdbc, PyUnicode_AsUTF8(databaseObj), SQL_NTS, SQL_DRIVER_NOPROMPT, rc);
23592359
LogMsg(DEBUG, messageStr);
23602360
}
23612361
else
@@ -2378,10 +2378,10 @@ static PyObject *_python_ibm_db_connect_helper(PyObject *self, PyObject *args, i
23782378
PyUnicode_GetLength(uidObj) * 2,
23792379
password,
23802380
PyUnicode_GetLength(passwordObj) * 2);
2381-
snprintf(messageStr, sizeof(messageStr), "SQLConnectW called with parameters: conn_res->hdbc=%p, database=%ls, databaseLen=%zd, uid=%ls, uidLen=%zd, password=%ls, passwordLen=%zd and returned rc=%d",
2382-
(void *)conn_res->hdbc, database,
2383-
PyUnicode_GetLength(databaseObj) * 2, uid,
2384-
PyUnicode_GetLength(uidObj) * 2, password,
2381+
snprintf(messageStr, sizeof(messageStr), "SQLConnectW called with parameters: conn_res->hdbc=%p, database=%s, databaseLen=%zd, uid=%s, uidLen=%zd, password=%s, passwordLen=%zd and returned rc=%d",
2382+
(void *)conn_res->hdbc, PyUnicode_AsUTF8(databaseObj),
2383+
PyUnicode_GetLength(databaseObj) * 2, PyUnicode_AsUTF8(uidObj),
2384+
PyUnicode_GetLength(uidObj) * 2, PyUnicode_AsUTF8(passwordObj),
23852385
PyUnicode_GetLength(passwordObj) * 2, rc);
23862386
LogMsg(DEBUG, messageStr);
23872387
#else
@@ -2392,10 +2392,10 @@ static PyObject *_python_ibm_db_connect_helper(PyObject *self, PyObject *args, i
23922392
PyUnicode_GetLength(uidObj),
23932393
password,
23942394
PyUnicode_GetLength(passwordObj));
2395-
snprintf(messageStr, sizeof(messageStr), "SQLConnectW called with parameters: conn_res->hdbc=%p, database=%ls, databaseLen=%zd, uid=%ls, uidLen=%zd, password=%ls, passwordLen=%zd and returned rc=%d",
2396-
(void *)conn_res->hdbc, database,
2397-
PyUnicode_GetLength(databaseObj), uid,
2398-
PyUnicode_GetLength(uidObj), password,
2395+
snprintf(messageStr, sizeof(messageStr), "SQLConnectW called with parameters: conn_res->hdbc=%p, database=%s, databaseLen=%zd, uid=%s, uidLen=%zd, password=%s, passwordLen=%zd and returned rc=%d",
2396+
(void *)conn_res->hdbc, PyUnicode_AsUTF8(databaseObj),
2397+
PyUnicode_GetLength(databaseObj), PyUnicode_AsUTF8(uidObj),
2398+
PyUnicode_GetLength(uidObj), PyUnicode_AsUTF8(passwordObj),
23992399
PyUnicode_GetLength(passwordObj), rc);
24002400
LogMsg(DEBUG, messageStr);
24012401
#endif

0 commit comments

Comments
 (0)