diff options
Diffstat (limited to 'protocols/Xfire')
-rw-r--r-- | protocols/Xfire/src/Xfire_icon_mng.cpp | 2 | ||||
-rw-r--r-- | protocols/Xfire/src/Xfire_voicechat.cpp | 7 | ||||
-rw-r--r-- | protocols/Xfire/src/client.cpp | 2 | ||||
-rw-r--r-- | protocols/Xfire/src/iniupdater.cpp | 28 | ||||
-rw-r--r-- | protocols/Xfire/src/main.cpp | 19 | ||||
-rw-r--r-- | protocols/Xfire/src/options.cpp | 8 | ||||
-rw-r--r-- | protocols/Xfire/src/pwd_dlg.cpp | 2 | ||||
-rw-r--r-- | protocols/Xfire/src/searching4games.cpp | 47 | ||||
-rw-r--r-- | protocols/Xfire/src/tools.cpp | 12 | ||||
-rw-r--r-- | protocols/Xfire/src/variables.cpp | 10 |
10 files changed, 59 insertions, 78 deletions
diff --git a/protocols/Xfire/src/Xfire_icon_mng.cpp b/protocols/Xfire/src/Xfire_icon_mng.cpp index b469e44595..90bf845253 100644 --- a/protocols/Xfire/src/Xfire_icon_mng.cpp +++ b/protocols/Xfire/src/Xfire_icon_mng.cpp @@ -28,7 +28,7 @@ unsigned int Xfire_icon_mng::getGameIconId(unsigned int gameid) { //gameicon mit hilfe von id zurückliefern
HICON Xfire_icon_mng::getGameIconFromId(unsigned int id) {
//id nur im bereich zurückliefern
- if (id<0 || id>iconcache.size() - 1)
+ if (id>iconcache.size() - 1)
return NULL;
return iconcache.at(id).hicon;
diff --git a/protocols/Xfire/src/Xfire_voicechat.cpp b/protocols/Xfire/src/Xfire_voicechat.cpp index 878ffc951c..dfb5f89a0a 100644 --- a/protocols/Xfire/src/Xfire_voicechat.cpp +++ b/protocols/Xfire/src/Xfire_voicechat.cpp @@ -215,8 +215,7 @@ HMODULE Xfire_voicechat::loadTSR(char* path, BOOL nolocaltest) { //teamspeak 3 detection, benötigt ts3plugin
-BOOL Xfire_voicechat::checkforTS3(SendGameStatus2Packet* packet) {
- ts3IPPORT* ipport = NULL;
+BOOL Xfire_voicechat::checkforTS3(SendGameStatus2Packet *packet) {
//kein gültiger verweis?
if (packet == NULL)
return FALSE;
@@ -226,7 +225,7 @@ BOOL Xfire_voicechat::checkforTS3(SendGameStatus2Packet* packet) { if (hMapObject == NULL)
return FALSE;
//versuch ipport zubesorgen
- ipport = (ts3IPPORT *)MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, sizeof(ts3IPPORT));
+ ts3IPPORT *ipport = (ts3IPPORT *)MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, sizeof(ts3IPPORT));
//fehler beim zugriff auf filemap?
if (ipport == NULL)
{
@@ -362,7 +361,7 @@ BOOL Xfire_voicechat::checkforMumble(SendGameStatus2Packet* packet) { }
}
}
- delete ptab;
+ free(ptab);
}
return FALSE;
diff --git a/protocols/Xfire/src/client.cpp b/protocols/Xfire/src/client.cpp index 7fa31f99bc..024cfc16d9 100644 --- a/protocols/Xfire/src/client.cpp +++ b/protocols/Xfire/src/client.cpp @@ -92,7 +92,7 @@ using namespace std; struct sockaddr_in sa;
int iLen = sizeof(sa);
getsockname(socket->m_sock, (SOCKADDR*)&sa, &iLen);
- strcpy(this->localaddr,inet_ntoa(sa.sin_addr));
+ strncpy(this->localaddr,inet_ntoa(sa.sin_addr), sizeof(this->localaddr)-1);
this->llocaladdr=inet_addr(this->localaddr);
packetReader->setSocket(socket);
diff --git a/protocols/Xfire/src/iniupdater.cpp b/protocols/Xfire/src/iniupdater.cpp index f5f1e97aeb..bbd63279b8 100644 --- a/protocols/Xfire/src/iniupdater.cpp +++ b/protocols/Xfire/src/iniupdater.cpp @@ -49,17 +49,13 @@ INT_PTR CALLBACK DlgUpdateDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR void UpdateMyXFireIni(LPVOID dummy) {
char request[1024];
- char file[1024];
- char file2[1024];
- char file3[1024];
+ char *inipath = XFireGetFoldersPath("IniFile");
//ini pfad rausbekommen
- strcpy(file, XFireGetFoldersPath("IniFile"));
- strcpy(file2, file);
- strcpy(file3, file);
- strcat(file, "xfire_games.new");
- strcat(file2, "xfire_games.ini");
- strcat(file3, "xfire_games.old");
+ char file[1024], file2[1024], file3[1024];
+ mir_snprintf(file,SIZEOF(file), "%sxfire_games.new",inipath);
+ mir_snprintf(file2,SIZEOF(file2), "%sxfire_games.ini",inipath);
+ mir_snprintf(file3,SIZEOF(file3), "%sxfire_games.old",inipath);
mir_snprintf(request, SIZEOF(request), "%s%d", INI_URLREQUEST, getfilesize(file2));
@@ -89,17 +85,13 @@ void UpdateMyXFireIni(LPVOID dummy) { void UpdateMyIcons(LPVOID dummy) {
char request[1024];
- char file[1024];
- char file2[1024];
- char file3[1024];
+ char *inipath = XFireGetFoldersPath("IconsFile");
//ini pfad rausbekommen
- strcpy(file, XFireGetFoldersPath("IconsFile"));
- strcpy(file2, file);
- strcpy(file3, file);
- strcat(file, "icons.new");
- strcat(file2, "icons.dll");
- strcat(file3, "icons.old");
+ char file[1024], file2[1024], file3[1024];
+ mir_snprintf(file,SIZEOF(file), "%sxfire_games.new",inipath);
+ mir_snprintf(file2,SIZEOF(file2), "%sxfire_games.ini",inipath);
+ mir_snprintf(file3,SIZEOF(file3), "%sxfire_games.old",inipath);
mir_snprintf(request, SIZEOF(request), "%s%d", ICO_URLREQUEST, getfilesize(file2));
diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp index f3e4af5b70..1fa30287c6 100644 --- a/protocols/Xfire/src/main.cpp +++ b/protocols/Xfire/src/main.cpp @@ -1368,18 +1368,20 @@ INT_PTR SendMessage(WPARAM wParam, LPARAM lParam) DBVARIANT dbv;
int sended = 0;
- db_get_s(ccs->hContact, protocolname, "Username", &dbv);
+ if(db_get_s(ccs->hContact, protocolname, "Username", &dbv))
+ return 0;
+
if (myClient != NULL)
if (myClient->client->connected&&db_get_w(ccs->hContact, protocolname, "Status", -1) != ID_STATUS_OFFLINE)
{
- myClient->sendmsg(dbv.pszVal, ptrA(mir_utf8encode((char*)ccs->lParam)));
- mir_forkthread(SendAck, (void*)ccs->hContact);
- sended = 1;
+ myClient->sendmsg(dbv.pszVal, ptrA(mir_utf8encode((char*)ccs->lParam)));
+ mir_forkthread(SendAck, (void*)ccs->hContact);
+ sended = 1;
}
else mir_forkthread(SendBadAck, (void*)ccs->hContact);
- db_free(&dbv);
- return sended;
+ db_free(&dbv);
+ return sended;
}
//=======================================================
@@ -3094,8 +3096,7 @@ void CreateGroup(char*grpn, char*field) { char temp[255];
DBVARIANT dbv;
mir_snprintf(temp, SIZEOF(temp), "%d", val - 1);
- db_get_s(NULL, "CListGroups", temp, &dbv);
- if (dbv.pszVal != NULL)
+ if (!db_get_s(NULL, "CListGroups", temp, &dbv))
{
mir_snprintf(grp, SIZEOF(grp), "%s\\%s", &dbv.pszVal[1], grpn);
db_free(&dbv);
@@ -3410,7 +3411,7 @@ INT_PTR GetAvatarInfo(WPARAM wParam, LPARAM lParam) { DBVARIANT dbv;
if (!db_get(pai->hContact, "ContactPhoto", "File", &dbv))
{
- strcpy(pai->filename, dbv.pszVal);
+ strncpy(pai->filename, dbv.pszVal, sizeof(pai->filename)-1);
db_free(&dbv);
}
else
diff --git a/protocols/Xfire/src/options.cpp b/protocols/Xfire/src/options.cpp index d25224d503..0095be37d5 100644 --- a/protocols/Xfire/src/options.cpp +++ b/protocols/Xfire/src/options.cpp @@ -139,8 +139,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetWindowLongPtr(hwndTree, GWL_STYLE, GetWindowLongPtr(hwndTree, GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES); SendMessage(hwndDlg, DM_REBUILD_TREE, 0, 0); - strcpy(inipath, XFireGetFoldersPath("IniFile")); - strcat(inipath, "xfire_games.ini"); + mir_snprintf(inipath, XFIRE_MAX_STATIC_STRING_LEN,"%sxfire_games.ini",XFireGetFoldersPath("IniFile")); FILE * f = fopen(inipath, "r"); if (f != NULL) @@ -154,9 +153,8 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR EnableDlgItem(hwndDlg, IDC_SETUPGAMES, FALSE); inifound = FALSE; } - - strcpy(inipath, XFireGetFoldersPath("IconsFile")); - strcat(inipath, "icons.dll"); + + mir_snprintf(inipath, XFIRE_MAX_STATIC_STRING_LEN,"%sicons.dll",XFireGetFoldersPath("IconsFile")); f = fopen(inipath, "r"); if (f != NULL) diff --git a/protocols/Xfire/src/pwd_dlg.cpp b/protocols/Xfire/src/pwd_dlg.cpp index dbb8415e80..31108404a8 100644 --- a/protocols/Xfire/src/pwd_dlg.cpp +++ b/protocols/Xfire/src/pwd_dlg.cpp @@ -36,7 +36,7 @@ INT_PTR CALLBACK DlgPwProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) BOOL ShowPwdDlg(char* pw) {
//kein gültiges ziel für das eingegebene passwort
- if (&pw == NULL)
+ if (pw == NULL)
return FALSE;
if (DialogBox(hinstance, MAKEINTRESOURCE(IDD_SETNICKNAME), NULL, DlgPwProc))
diff --git a/protocols/Xfire/src/searching4games.cpp b/protocols/Xfire/src/searching4games.cpp index 93851ee494..2522a06f9b 100644 --- a/protocols/Xfire/src/searching4games.cpp +++ b/protocols/Xfire/src/searching4games.cpp @@ -46,10 +46,6 @@ BOOL CheckPath(char*ppath, char*pathwildcard = NULL) pos = strchr(ppath, '*');
if (pos)
{
- HANDLE fHandle;
- WIN32_FIND_DATAA wfd;
- BOOL weiter = TRUE;
-
if (pathwildcard)
{
strcpy_s(pathwildcard, XFIRE_MAX_STATIC_STRING_LEN, ppath);
@@ -60,26 +56,29 @@ BOOL CheckPath(char*ppath, char*pathwildcard = NULL) pos++;
//versuch die exe zu finden
- fHandle = FindFirstFileA(ppath, &wfd); // . skippen
- FindNextFileA(fHandle, &wfd); // .. auch skippen
-
- while ((FindNextFileA(fHandle, &wfd) && weiter == TRUE)) // erstes file
- {
- if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // nur verzeichnisse sind interessant
+ WIN32_FIND_DATAA wfd;
+ HANDLE fHandle = FindFirstFileA(ppath, &wfd); // . skippen
+ if (fHandle == INVALID_HANDLE_VALUE)
+ return FALSE;
+ if(FindNextFileA(fHandle, &wfd)) { // .. auch skippen
+ while (FindNextFileA(fHandle, &wfd)) // erstes file
{
- char temp[XFIRE_MAX_STATIC_STRING_LEN];
-
- strcpy(temp, ppath);
- *(temp + strlen(temp) - 1) = 0;
- strcat(temp, wfd.cFileName);
- strcat(temp, "\\");
- strcat(temp, pos);
-
- if (GetFileAttributesA(temp) != 0xFFFFFFFF) { //exe vorhanden???? unt hint?
- //gefundenes in path kopieren
- FindClose(fHandle);
- strcpy(ppath, temp);
- return TRUE;
+ if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // nur verzeichnisse sind interessant
+ {
+ char temp[XFIRE_MAX_STATIC_STRING_LEN];
+
+ strncpy(temp, ppath,XFIRE_MAX_STATIC_STRING_LEN-1);
+ *(temp + strlen(temp) - 1) = 0;
+ strncat(temp, wfd.cFileName,XFIRE_MAX_STATIC_STRING_LEN-1);
+ strncat(temp, "\\",XFIRE_MAX_STATIC_STRING_LEN-1);
+ strncat(temp, pos,XFIRE_MAX_STATIC_STRING_LEN-1);
+
+ if (GetFileAttributesA(temp) != 0xFFFFFFFF) { //exe vorhanden???? unt hint?
+ //gefundenes in path kopieren
+ FindClose(fHandle);
+ strcpy(ppath, temp);
+ return TRUE;
+ }
}
}
}
@@ -291,7 +290,7 @@ void Scan4Games(LPVOID lparam) pos++;
pos2 = strrchr(pos, '\\'); //key trennen
- if (pos != 0)
+ if (pos2 != 0)
{
*pos2 = 0;
pos2++;
diff --git a/protocols/Xfire/src/tools.cpp b/protocols/Xfire/src/tools.cpp index 791b1d2be8..7675e55762 100644 --- a/protocols/Xfire/src/tools.cpp +++ b/protocols/Xfire/src/tools.cpp @@ -211,7 +211,7 @@ char* GetLaunchPath(char*launch) if (launch == NULL) return temp; - strcpy(temp, launch); + strncpy(temp, launch, XFIRE_MAX_STATIC_STRING_LEN -1); while (*p != 0 && *f != 0) { @@ -473,7 +473,11 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i for (int I = 0; I < maxuppackets; I++) //maximal 4 packete, das reicht { int msize = recv(s, (char*)&temp, sizeof(mpacket), 0); - if (msize) //empfangen + if (msize == SOCKET_ERROR) + { + XFireLog("recv() error %d", WSAGetLastError()); + } + else if (msize) //empfangen { /*DUMP("Packet empfangen",""); DUMP("Dump Full packet##############",""); @@ -532,10 +536,6 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i }*/ } } - else if (msize == SOCKET_ERROR) - { - XFireLog("recv() error %d", WSAGetLastError()); - } } closesocket(s); //socket zumachn lastip = 0; diff --git a/protocols/Xfire/src/variables.cpp b/protocols/Xfire/src/variables.cpp index eff15227c4..45873fd9a4 100644 --- a/protocols/Xfire/src/variables.cpp +++ b/protocols/Xfire/src/variables.cpp @@ -103,13 +103,7 @@ char* Varxfireserverip(ARGUMENTSINFO *ai) { if (ai->cbSize < sizeof(ARGUMENTSINFO))
return NULL;
- if (ai->fi->hContact == NULL)
- {
- ai->flags = AIF_FALSE;
- return mir_strdup("");
- }
- else
- {
+ if (ai->fi->hContact != NULL) {
char temp[24];
DBVARIANT dbv3;
if (!db_get(ai->fi->hContact, protocolname, "ServerIP", &dbv3))
@@ -118,8 +112,6 @@ char* Varxfireserverip(ARGUMENTSINFO *ai) { db_free(&dbv3);
return mir_strdup(temp);
}
- ai->flags = AIF_FALSE;
- return mir_strdup("");
}
ai->flags = AIF_FALSE;
|