From fc3a4607ee5cfe9e7cfed8d63e2cb1d549f61d92 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 22 Sep 2014 14:06:14 +0000 Subject: _tcsncpy -> _tcsncpy_s; strncpy -> strncpy_s git-svn-id: http://svn.miranda-ng.org/main/trunk@10557 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/JabberG/src/jabber_thread.cpp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'protocols/JabberG/src/jabber_thread.cpp') diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 12691746bb..70a61cf5fb 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -304,13 +304,13 @@ LBL_FatalError: TCHAR jidStr[512]; mir_sntprintf(jidStr, SIZEOF(jidStr), _T("%s@%S/%s"), info->username, info->server, info->resource); - _tcsncpy(info->fullJID, jidStr, SIZEOF(info->fullJID)-1); + _tcsncpy_s(info->fullJID, jidStr, SIZEOF(info->fullJID)-1); - if (m_options.SavePassword == FALSE) { - if (*m_savedPassword) { - _tcsncpy(info->password, m_savedPassword, SIZEOF(info->password)); - info->password[ SIZEOF(info->password)-1] = '\0'; - } + if (m_options.UseDomainLogin) // in the case of NTLM auth we have no need in password + info->password[0] = 0; + else if (!m_options.SavePassword) { // we have to enter a password manually. have we done it before? + if (m_savedPassword != NULL) + _tcsncpy_s(info->password, SIZEOF(info->password), m_savedPassword, _TRUNCATE); else { mir_sntprintf(jidStr, SIZEOF(jidStr), _T("%s@%S"), info->username, info->server); @@ -328,23 +328,18 @@ LBL_FatalError: goto LBL_FatalError; } - if (param.saveOnlinePassword) lstrcpy(m_savedPassword, param.onlinePassword); - else *m_savedPassword = 0; - - _tcsncpy(info->password, param.onlinePassword, SIZEOF(info->password)); - info->password[ SIZEOF(info->password)-1] = '\0'; + m_savedPassword = (param.saveOnlinePassword) ? mir_tstrdup(param.onlinePassword) : NULL; + _tcsncpy_s(info->password, SIZEOF(info->password), param.onlinePassword, _TRUNCATE); } } else { - TCHAR *passw = getTStringA(NULL, "Password"); - if (passw == NULL) { + ptrT tszPassw(getTStringA(NULL, "Password")); + if (tszPassw == NULL) { JLoginFailed(LOGINERR_BADUSERID); debugLogA("Thread ended, password is not configured"); goto LBL_FatalError; } - _tcsncpy(info->password, passw, SIZEOF(info->password)); - info->password[SIZEOF(info->password)-1] = '\0'; - mir_free(passw); + _tcsncpy_s(info->password, SIZEOF(info->password), tszPassw, _TRUNCATE); } } @@ -378,7 +373,7 @@ LBL_FatalError: if (info->manualHost[0] == 0) { info->xmpp_client_query(); if (info->s == NULL) { - strncpy(info->manualHost, info->server, SIZEOF(info->manualHost)); + strncpy_s(info->manualHost, info->server, _TRUNCATE); info->s = WsConnect(info->manualHost, info->port); } } -- cgit v1.2.3