diff options
Diffstat (limited to 'plugins/SecureIM/src')
-rw-r--r-- | plugins/SecureIM/src/commonheaders.cpp | 9 | ||||
-rw-r--r-- | plugins/SecureIM/src/crypt_dll.cpp | 14 | ||||
-rw-r--r-- | plugins/SecureIM/src/crypt_lists.cpp | 8 | ||||
-rw-r--r-- | plugins/SecureIM/src/crypt_popups.cpp | 4 | ||||
-rw-r--r-- | plugins/SecureIM/src/loadlib.cpp | 9 | ||||
-rw-r--r-- | plugins/SecureIM/src/loadlib.h | 1 | ||||
-rw-r--r-- | plugins/SecureIM/src/main.cpp | 5 | ||||
-rw-r--r-- | plugins/SecureIM/src/options.cpp | 76 | ||||
-rw-r--r-- | plugins/SecureIM/src/svcs_proto.cpp | 15 |
9 files changed, 83 insertions, 58 deletions
diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp index 8f432bb761..28e8dc4e52 100644 --- a/plugins/SecureIM/src/commonheaders.cpp +++ b/plugins/SecureIM/src/commonheaders.cpp @@ -87,10 +87,11 @@ void CopyToClipboard(HWND hwnd, LPSTR msg) mir_strcpy(lpstrCopy, msg);
GlobalUnlock(hglbCopy);
- OpenClipboard(NULL);
- EmptyClipboard();
- SetClipboardData(CF_TEXT, hglbCopy);
- CloseClipboard();
+ if(OpenClipboard(NULL)) {
+ EmptyClipboard();
+ SetClipboardData(CF_TEXT, hglbCopy);
+ CloseClipboard();
+ }
}
HANDLE hNetlibUser;
diff --git a/plugins/SecureIM/src/crypt_dll.cpp b/plugins/SecureIM/src/crypt_dll.cpp index 9390367d93..d7c57ea17a 100644 --- a/plugins/SecureIM/src/crypt_dll.cpp +++ b/plugins/SecureIM/src/crypt_dll.cpp @@ -187,13 +187,15 @@ BOOL LoadKeyPGP(pUinKey ptr) int mode = db_get_b(ptr->hContact, MODULENAME, "pgp_mode", 255);
if (mode == 0) {
DBVARIANT dbv;
- db_get(ptr->hContact, MODULENAME, "pgp", &dbv);
- BOOL r = (dbv.type == DBVT_BLOB);
- if (r) pgp_set_keyid(ptr->cntx, (PVOID)dbv.pbVal);
- db_free(&dbv);
- return r;
+ if(!db_get(ptr->hContact, MODULENAME, "pgp", &dbv)) {
+ BOOL r = (dbv.type == DBVT_BLOB);
+ if (r)
+ pgp_set_keyid(ptr->cntx, (PVOID)dbv.pbVal);
+ db_free(&dbv);
+ return r;
+ }
}
- if (mode == 1) {
+ else if (mode == 1) {
LPSTR key = db_get_sa(ptr->hContact, MODULENAME, "pgp");
if (key) {
pgp_set_key(ptr->cntx, key);
diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp index 64de3c3fc1..e15f612b35 100644 --- a/plugins/SecureIM/src/crypt_lists.cpp +++ b/plugins/SecureIM/src/crypt_lists.cpp @@ -30,7 +30,7 @@ void loadSupportedProtocols() SupPro *p = (SupPro*)mir_calloc(sizeof(SupPro));
p->name = mir_strdup(protos[i]->szModuleName);
if (szNames && p->name) {
- char tmp[128]; strcpy(tmp, p->name); strcat(tmp, ":");
+ char tmp[128]; strncpy(tmp, p->name, sizeof(tmp)-1); strncat(tmp, ":", sizeof(tmp)-1);
LPSTR szName = strstr(szNames, tmp);
if (szName) {
szName = strchr(szName, ':');
@@ -40,8 +40,10 @@ void loadSupportedProtocols() if (szName) {
p->split_on = atoi(++szName); p->tsplit_on = p->split_on;
szName = strchr(szName, ':');
- if (szName)
- p->split_off = atoi(++szName); p->tsplit_off = p->split_off;
+ if (szName) {
+ p->split_off = atoi(++szName);
+ p->tsplit_off = p->split_off;
+ }
}
}
}
diff --git a/plugins/SecureIM/src/crypt_popups.cpp b/plugins/SecureIM/src/crypt_popups.cpp index a3c3a48016..f6f0a3396c 100644 --- a/plugins/SecureIM/src/crypt_popups.cpp +++ b/plugins/SecureIM/src/crypt_popups.cpp @@ -42,9 +42,9 @@ void showPopup(LPCSTR lpzText, MCONTACT hContact, HICON hIcon, UINT type) ppd.lchContact = hContact; //Be sure to use a GOOD handle, since this will not be checked.
ppd.lchIcon = hIcon;
LPWSTR lpwzContactName = (LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GSMDF_UNICODE);
- wcscpy(ppd.lpwzContactName, lpwzContactName);
+ wcsncpy(ppd.lpwzContactName, lpwzContactName, MAX_CONTACTNAME-1);
LPWSTR lpwzText = mir_a2u(lpzText);
- wcscpy(ppd.lpwzText, TranslateW(lpwzText));
+ wcsncpy(ppd.lpwzText, TranslateW(lpwzText),MAX_SECONDLINE-1);
mir_free(lpwzText);
ppd.colorBack = colorBack;
ppd.colorText = colorText;
diff --git a/plugins/SecureIM/src/loadlib.cpp b/plugins/SecureIM/src/loadlib.cpp index 7ecb9ef0dc..ebe2fab802 100644 --- a/plugins/SecureIM/src/loadlib.cpp +++ b/plugins/SecureIM/src/loadlib.cpp @@ -2,11 +2,12 @@ CRYPTOPP_INFO cpp;
+HMODULE h;
BOOL loadlib(void)
{
- HMODULE h = LoadLibraryA("plugins/cryptopp.dll");
+ h = LoadLibrary(_T("plugins/cryptopp.dll"));
if (h == NULL) {
- h = LoadLibraryA("cryptopp.dll");
+ h = LoadLibrary(_T("cryptopp.dll"));
if (h == NULL) return 0;
}
@@ -72,3 +73,7 @@ BOOL loadlib(void) return (cpp_get_version() >= 0x01000403);
}
+
+void freelib() {
+ FreeLibrary(h);
+}
\ No newline at end of file diff --git a/plugins/SecureIM/src/loadlib.h b/plugins/SecureIM/src/loadlib.h index ecf7ee7c8c..bed84c019d 100644 --- a/plugins/SecureIM/src/loadlib.h +++ b/plugins/SecureIM/src/loadlib.h @@ -2,6 +2,7 @@ #define __LOADLIB_H__
BOOL loadlib(void);
+void freelib();
typedef HANDLE (__cdecl * _cpp_create_context) (int);
typedef void (__cdecl * _cpp_delete_context) (HANDLE);
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index c1e5af66e5..8abf787e46 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -163,11 +163,11 @@ static int onModulesLoaded(WPARAM, LPARAM) LPSTR tmp = db_get_sa(0, MODULENAME, "gpgExec");
if (tmp) {
- strncpy(gpgexec, tmp, sizeof(gpgexec));
+ strncpy(gpgexec, tmp, sizeof(gpgexec)-1);
mir_free(tmp);
}
if (tmp = db_get_sa(0, MODULENAME, "gpgHome")) {
- strncpy(gpghome, tmp, sizeof(gpghome));
+ strncpy(gpghome, tmp, sizeof(gpghome)-1);
mir_free(tmp);
}
@@ -390,5 +390,6 @@ extern "C" __declspec(dllexport) int __cdecl Load(void) extern "C" __declspec(dllexport) int __cdecl Unload()
{
DeleteCriticalSection(&localQueueMutex);
+ freelib();
return 0;
}
diff --git a/plugins/SecureIM/src/options.cpp b/plugins/SecureIM/src/options.cpp index 49ff240836..d59beef298 100644 --- a/plugins/SecureIM/src/options.cpp +++ b/plugins/SecureIM/src/options.cpp @@ -1400,14 +1400,14 @@ void setListViewIcon(HWND hLV, UINT iItem, pUinKey ptr) void setListViewMode(HWND hLV, UINT iItem, UINT iMode)
{
char tmp[256];
- strncpy(tmp, Translate(sim231[iMode]), sizeof(tmp));
+ strncpy(tmp, Translate(sim231[iMode]), sizeof(tmp)-1);
LV_SetItemTextA(hLV, iItem, 2, tmp);
}
void setListViewStatus(HWND hLV, UINT iItem, UINT iStatus)
{
char tmp[128];
- strncpy(tmp, Translate(sim232[iStatus]), sizeof(tmp));
+ strncpy(tmp, Translate(sim232[iStatus]), sizeof(tmp)-1);
LV_SetItemTextA(hLV, iItem, 3, tmp);
}
@@ -1421,7 +1421,7 @@ UINT getListViewPSK(HWND hLV, UINT iItem) void setListViewPSK(HWND hLV, UINT iItem, UINT iStatus)
{
char str[128];
- strncpy(str, (iStatus) ? Translate(sim206) : "-", sizeof(str));
+ strncpy(str, (iStatus) ? Translate(sim206) : "-", sizeof(str)-1);
LV_SetItemTextA(hLV, iItem, 4, str);
}
@@ -1435,7 +1435,7 @@ UINT getListViewPUB(HWND hLV, UINT iItem) void setListViewPUB(HWND hLV, UINT iItem, UINT iStatus)
{
char str[128];
- strncpy(str, (iStatus) ? Translate(sim233) : "-", sizeof(str));
+ strncpy(str, (iStatus) ? Translate(sim233) : "-", sizeof(str)-1);
LV_SetItemTextA(hLV, iItem, 4, str);
LPSTR sha = NULL;
@@ -1461,7 +1461,7 @@ int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) {
pUinKey p1 = pUinKey(lParam1), p2 = pUinKey(lParam2);
char t1[NAMSIZE], t2[NAMSIZE];
- int s, d, m = 1;
+ int s=0, d=0, m = 1;
DBVARIANT dbv1 = { 0 }, dbv2 = { 0 };
if (lParamSort & 0x100) {
@@ -1490,30 +1490,38 @@ int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) return (s - d)*m;
case 0x13:
- db_get_s(p1->hContact, MODULENAME, "pgp_abbr", &dbv1);
- db_get_s(p2->hContact, MODULENAME, "pgp_abbr", &dbv2);
- s = (dbv1.type == DBVT_ASCIIZ);
- d = (dbv2.type == DBVT_ASCIIZ);
- if (s && d) {
- s = strcmp(dbv1.pszVal, dbv2.pszVal);
- d = 0;
+ if(!db_get_s(p1->hContact, MODULENAME, "pgp_abbr", &dbv1)){
+ if(!db_get_s(p2->hContact, MODULENAME, "pgp_abbr", &dbv2)) {
+ s = (dbv1.type == DBVT_ASCIIZ);
+ d = (dbv2.type == DBVT_ASCIIZ);
+ if (s && d) {
+ s = strcmp(dbv1.pszVal, dbv2.pszVal);
+ d = 0;
+ }
+ db_free(&dbv1);
+ }
+ db_free(&dbv2);
+ return (s - d)*m;
}
- db_free(&dbv1);
- db_free(&dbv2);
- return (s - d)*m;
+ else
+ return 0;
case 0x23:
- db_get_s(p1->hContact, MODULENAME, "gpg", &dbv1);
- db_get_s(p2->hContact, MODULENAME, "gpg", &dbv2);
- s = (dbv1.type == DBVT_ASCIIZ);
- d = (dbv2.type == DBVT_ASCIIZ);
- if (s && d) {
- s = strcmp(dbv1.pszVal, dbv2.pszVal);
- d = 0;
+ if(!db_get_s(p1->hContact, MODULENAME, "gpg", &dbv1)) {
+ s = (dbv1.type == DBVT_ASCIIZ);
+ if(!db_get_s(p2->hContact, MODULENAME, "gpg", &dbv2)) {
+ d = (dbv2.type == DBVT_ASCIIZ);
+ if (s && d) {
+ s = strcmp(dbv1.pszVal, dbv2.pszVal);
+ d = 0;
+ }
+ db_free(&dbv1);
+ }
+ db_free(&dbv2);
+ return (s - d)*m;
}
- db_free(&dbv1);
- db_free(&dbv2);
- return (s - d)*m;
+ else
+ return 0;
case 0x04:
s = p1->tstatus;
@@ -1521,13 +1529,17 @@ int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) return (s - d)*m;
case 0x05:
- db_get_s(p1->hContact, MODULENAME, "PSK", &dbv1);
- s = (dbv1.type == DBVT_ASCIIZ);
- db_free(&dbv1);
- db_get_s(p2->hContact, MODULENAME, "PSK", &dbv2);
- d = (dbv2.type == DBVT_ASCIIZ);
- db_free(&dbv2);
- return (s - d)*m;
+ if(!db_get_s(p1->hContact, MODULENAME, "PSK", &dbv1)) {
+ s = (dbv1.type == DBVT_ASCIIZ);
+ if (!db_get_s(p2->hContact, MODULENAME, "PSK", &dbv2)) {
+ d = (dbv2.type == DBVT_ASCIIZ);
+ db_free(&dbv2);
+ }
+ db_free(&dbv1);
+ return (s - d)*m;
+ }
+ else
+ return 0;
}
return 0;
}
diff --git a/plugins/SecureIM/src/svcs_proto.cpp b/plugins/SecureIM/src/svcs_proto.cpp index e583506158..0ebc1de9ed 100644 --- a/plugins/SecureIM/src/svcs_proto.cpp +++ b/plugins/SecureIM/src/svcs_proto.cpp @@ -487,11 +487,10 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) // pass unhandled messages
if (!ptr || ssig == SiG_GAME || ssig == SiG_PGPM || ssig == SiG_SECU || ssig == SiG_SECP ||
- isChatRoom(pccsd->hContact) || stat == -1 ||
- (ssig == SiG_NONE && ptr->sendQueue) || (ssig == SiG_NONE && ptr->status == STATUS_DISABLED)) {
- return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
-
- Sent_NetLog("onSendMsg: pass unhandled");
+ isChatRoom(pccsd->hContact) || stat == -1 ||
+ (ssig == SiG_NONE && ptr->sendQueue) || (ssig == SiG_NONE && ptr->status == STATUS_DISABLED)) {
+ Sent_NetLog("onSendMsg: pass unhandled");
+ return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
}
//
@@ -840,9 +839,11 @@ int __cdecl onProtoAck(WPARAM wParam, LPARAM lParam) ACKDATA *ack = (ACKDATA*)lParam;
if (ack->type != ACKTYPE_FILE) return 0; //quit if not file transfer event
PROTOFILETRANSFERSTATUS *f = (PROTOFILETRANSFERSTATUS*)ack->lParam;
+ if (!f)
+ return 0;
pUinKey ptr = getUinKey(ack->hContact);
- if (!ptr || (f && (f->flags & PFTS_SENDING) && !bSFT)) return 0;
+ if (!ptr || ((f->flags & PFTS_SENDING) && !bSFT)) return 0;
if (isContactSecured(ack->hContact)&SECURED) {
switch (ack->result) {
@@ -893,7 +894,7 @@ int __cdecl onProtoAck(WPARAM wParam, LPARAM lParam) LPSTR p = strrchr(file_out, '.');
LPSTR x = strrchr(file_out, '\\');
if (p > x) {
- strcpy(buf, p);
+ strncpy(buf, p, sizeof(buf)-1);
pos = p;
}
for (int i = 1; i < 10000; i++) {
|