diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2015-03-27 22:07:31 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2015-03-27 22:07:31 +0000 |
commit | bcd3d5eedda6f93c8846f77848e950b4e78fcd81 (patch) | |
tree | 45861e1b56a4b9e4b41b3add563ae4b4612e324a /protocols/Yahoo/src/avatar.cpp | |
parent | 171d9d47bbccf67edf73042eaab8eec616bd5efb (diff) |
Yahoo:
- Fix for a broken URL
- minor bugfixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@12532 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Yahoo/src/avatar.cpp')
-rw-r--r-- | protocols/Yahoo/src/avatar.cpp | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/protocols/Yahoo/src/avatar.cpp b/protocols/Yahoo/src/avatar.cpp index f698adb092..9fb6eb893e 100644 --- a/protocols/Yahoo/src/avatar.cpp +++ b/protocols/Yahoo/src/avatar.cpp @@ -133,7 +133,7 @@ void CYahooProto::SendAvatar(const TCHAR *szFile) sf->filesize = statbuf.st_size;
wchar_t tszFilename[MAX_PATH];
- wcscpy(tszFilename, szFile);
+ wcsncpy(tszFilename, szFile, SIZEOF(szFile)-1);
GetShortPathNameW(szFile, tszFilename, SIZEOF(tszFilename));
char szFilename[MAX_PATH];
WideCharToMultiByte(CP_ACP, 0, tszFilename, -1, szFilename, MAX_PATH, 0, 0);
@@ -152,7 +152,6 @@ struct avatar_info{ void __cdecl CYahooProto::recv_avatarthread(void *pavt)
{
- PROTO_AVATAR_INFORMATIONT AI;
struct avatar_info *avt = ( avatar_info* )pavt;
int error = 0;
TCHAR buf[4096];
@@ -203,13 +202,11 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt) LOG(("No data??? Got %d bytes.", nlhrReply->dataLength));
error = 1;
} else {
- HANDLE myhFile;
-
GetAvatarFileName(hContact, buf, 1024, getByte(hContact, "AvatarType", 0));
DeleteFile(buf);
LOG(("Saving file: %s size: %u", buf, nlhrReply->dataLength));
- myhFile = CreateFile(buf,
+ HANDLE myhFile = CreateFile(buf,
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
@@ -244,11 +241,12 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt) free(avt->who);
free(avt->pic_url);
free(avt);
-
+
+ PROTO_AVATAR_INFORMATIONT AI;
AI.cbSize = sizeof AI;
AI.format = PA_FORMAT_PNG;
AI.hContact = hContact;
- _tcsncpy(AI.filename, buf, SIZEOF(AI.filename));
+ _tcsncpy(AI.filename, buf, SIZEOF(AI.filename)-1);
if (error)
setDword(hContact, "PictCK", 0);
@@ -450,11 +448,9 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p void CYahooProto::ext_got_picture_checksum(const char *me, const char *who, int cksum)
{
- MCONTACT hContact = 0;
-
LOG(("ext_yahoo_got_picture_checksum for %s checksum: %d", who, cksum));
- hContact = getbuddyH(who);
+ MCONTACT hContact = getbuddyH(who);
if (hContact == NULL) {
LOG(("Buddy Not Found. Skipping avatar update"));
return;
@@ -472,7 +468,7 @@ void CYahooProto::ext_got_picture_checksum(const char *me, const char *who, int // Need to delete the Avatar File!!
TCHAR szFile[MAX_PATH];
- GetAvatarFileName(hContact, szFile, sizeof szFile, 0);
+ GetAvatarFileName(hContact, szFile, SIZEOF(szFile)-1, 0);
DeleteFile(szFile);
// Reset the avatar and cleanup.
@@ -488,11 +484,9 @@ void CYahooProto::ext_got_picture_checksum(const char *me, const char *who, int void CYahooProto::ext_got_picture_update(const char *me, const char *who, int buddy_icon)
{
- MCONTACT hContact = 0;
-
LOG(("ext_got_picture_update for %s buddy_icon: %d", who, buddy_icon));
- hContact = getbuddyH(who);
+ MCONTACT hContact = getbuddyH(who);
if (hContact == NULL) {
LOG(("Buddy Not Found. Skipping avatar update"));
return;
@@ -806,12 +800,7 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam) DeleteFile(tszMyFile);
} else {
- DWORD dwPngSize, dw;
- BYTE* pResult;
- unsigned int hash;
- HANDLE hFile;
-
- hFile = CreateFile(tszFile,
+ HANDLE hFile = CreateFile(tszFile,
GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
@@ -822,10 +811,14 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam) if ( hFile == INVALID_HANDLE_VALUE )
return 1;
- dwPngSize = GetFileSize( hFile, NULL);
- if (( pResult = ( BYTE* )malloc( dwPngSize )) == NULL)
+ DWORD dwPngSize = GetFileSize( hFile, NULL);
+ BYTE *pResult = ( BYTE* )malloc(dwPngSize);
+ if (pResult == NULL) {
+ CloseHandle(hFile);
return 2;
+ }
+ DWORD dw;
ReadFile( hFile, pResult, dwPngSize, &dw, NULL);
CloseHandle( hFile );
@@ -842,7 +835,7 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam) SetEndOfFile( hFile);
CloseHandle( hFile );
- hash = YAHOO_avt_hash(( const char* )pResult, dwPngSize);
+ unsigned int hash = YAHOO_avt_hash(( const char* )pResult, dwPngSize);
free( pResult );
if ( hash ) {
|