summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-08-02 17:55:46 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-08-02 17:55:46 +0000
commit26a22a753462573077d2a8072fd2eb822a288d7d (patch)
treea8eebf3985fc57a53109ad8d6359ff010ac88158 /protocols/SkypeWeb
parent904cc94d119a5b7952cffe35e9023035a7a0c21c (diff)
SkypeWeb: pass_ptr - smart pointer for passwords
git-svn-id: http://svn.miranda-ng.org/main/trunk@14821 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb')
-rw-r--r--protocols/SkypeWeb/src/skype_db.h16
-rw-r--r--protocols/SkypeWeb/src/skype_login.cpp3
-rw-r--r--protocols/SkypeWeb/src/skype_options.cpp13
3 files changed, 22 insertions, 10 deletions
diff --git a/protocols/SkypeWeb/src/skype_db.h b/protocols/SkypeWeb/src/skype_db.h
index 48a8a86185..f4ea89184b 100644
--- a/protocols/SkypeWeb/src/skype_db.h
+++ b/protocols/SkypeWeb/src/skype_db.h
@@ -33,4 +33,20 @@ enum SKYPE_DB_EVENT_TYPE
#define SKYPE_SETTINGS_PASSWORD "Password"
#define SKYPE_SETTINGS_GROUP "DefaultGroup"
+class pass_ptr
+{
+ char* data;
+
+public:
+ __inline explicit pass_ptr() : data(NULL) {}
+ __inline explicit pass_ptr(char* _p) : data(_p) {}
+ __inline ~pass_ptr() { zero(); mir_free(data); }
+ __inline char* operator = (char * _p) { if (data){ zero(); mir_free(data); } data = _p; return data; }
+ __inline char* operator->() const { return data; }
+ __inline operator char *() const { return data; }
+ __inline operator INT_PTR() const { return (INT_PTR)data; }
+ __inline char * detach() { char *res = data; data = NULL; return res; }
+ __inline void zero(){ if (data) SecureZeroMemory(data, mir_strlen(data)); }
+};
+
#endif //_SKYPE_DB_H_ \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp
index ab650a5e0e..bec1edbcff 100644
--- a/protocols/SkypeWeb/src/skype_login.cpp
+++ b/protocols/SkypeWeb/src/skype_login.cpp
@@ -26,7 +26,7 @@ void CSkypeProto::Login()
requestQueue->Start();
int tokenExpires(getDword("TokenExpiresIn", 0));
ptrA szLogin(getStringA(SKYPE_SETTINGS_ID));
- ptrA szPassword(getStringA(SKYPE_SETTINGS_PASSWORD));
+ pass_ptr szPassword(getStringA(SKYPE_SETTINGS_PASSWORD));
if (szLogin == NULL || szPassword == NULL)
{
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
@@ -42,7 +42,6 @@ void CSkypeProto::Login()
else
SendRequest(new LoginOAuthRequest(szLogin, szPassword), &CSkypeProto::OnLoginOAuth);
}
- SecureZeroMemory(szPassword, mir_strlen(szPassword));
}
void CSkypeProto::OnLoginOAuth(const NETLIBHTTPREQUEST *response)
diff --git a/protocols/SkypeWeb/src/skype_options.cpp b/protocols/SkypeWeb/src/skype_options.cpp
index 4253930fba..fb59d1e157 100644
--- a/protocols/SkypeWeb/src/skype_options.cpp
+++ b/protocols/SkypeWeb/src/skype_options.cpp
@@ -45,17 +45,17 @@ void CSkypeOptionsMain::OnInitDialog()
m_password.SetTextA(ptrA(m_proto->getStringA("Password")));
m_place.Enable(!m_proto->getBool("UseHostName", false));
SendMessage(m_skypename.GetHwnd(), EM_LIMITTEXT, 32, 0);
- SendMessage(m_password.GetHwnd(), EM_LIMITTEXT, 20, 0);
+ SendMessage(m_password.GetHwnd(), EM_LIMITTEXT, 128, 0);
SendMessage(m_group.GetHwnd(), EM_LIMITTEXT, 64, 0);
}
void CSkypeOptionsMain::OnApply()
{
- ptrA szNewSkypename(m_skypename.GetTextA()),
- szNewPassword(m_password.GetTextA()),
- szOldSkypename(m_proto->getStringA(SKYPE_SETTINGS_ID)),
- szOldPassword(m_proto->getStringA("Password"));
+ ptrA szNewSkypename(m_skypename.GetTextA()),
+ szOldSkypename(m_proto->getStringA(SKYPE_SETTINGS_ID));
+ pass_ptr szNewPassword(m_password.GetTextA()),
+ szOldPassword(m_proto->getStringA("Password"));
if (mir_strcmpi(szNewSkypename, szOldSkypename) || mir_strcmp(szNewPassword, szOldPassword))
m_proto->delSetting("TokenExpiresIn");
@@ -64,9 +64,6 @@ void CSkypeOptionsMain::OnApply()
ptrT group(m_group.GetText());
if (mir_tstrlen(group) > 0 && !Clist_GroupExists(group))
Clist_CreateGroup(0, group);
-
- SecureZeroMemory(szNewPassword, mir_strlen(szNewPassword));
- SecureZeroMemory(szOldPassword, mir_strlen(szOldPassword));
}
/////////////////////////////////////////////////////////////////////////////////