summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-07-30 18:06:01 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-07-30 18:06:01 +0300
commit966a705e634e3c934f5ac14dce1524714d2b31f0 (patch)
tree7ba5b5be239b3ff2a4ce44c2fb14e16c004800b1 /plugins
parent5850e4aa99a509df796745e358bb59d9205a37c6 (diff)
fixes #4563 (SendSS: Crash with Imgur, Image Shack & Upload Pie)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.cpp7
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.h2
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp7
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp7
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp7
-rw-r--r--plugins/SendScreenshotPlus/src/stdafx.h1
-rw-r--r--plugins/SendScreenshotPlus/src/version.h2
7 files changed, 18 insertions, 15 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp
index 6321215b1d..19dc9957c4 100644
--- a/plugins/SendScreenshotPlus/src/CSend.cpp
+++ b/plugins/SendScreenshotPlus/src/CSend.cpp
@@ -45,8 +45,7 @@ CSend::CSend(HWND /*Owner*/, MCONTACT hContact, bool bAsync, bool bSilent) :
m_hSend(nullptr),
m_hOnSend(nullptr),
m_ErrorMsg(nullptr),
- m_ErrorTitle(nullptr),
- m_nlhr(REQUEST_POST)
+ m_ErrorTitle(nullptr)
{
SetContact(hContact);
}
@@ -165,7 +164,7 @@ INT_PTR CALLBACK CSend::ResultDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
}
else len = GetDlgItemText(hwndDlg, edtID, tmp, _countof(tmp));
- Utils_ClipboardCopy(MClipUnicode(CMStringW(tmp, len + 1)));
+ Utils_ClipboardCopy(MClipUnicode(CMStringW(tmp, (int)len + 1)));
if (LOWORD(wParam) == IDOK)
DestroyWindow(hwndDlg);
@@ -492,7 +491,7 @@ int CSend::HTTPFormCreate(MHttpRequest* nlhr, const char* url, HTTPFormData* frm
str.Append("\r\n\r\n");
/// add file content
- size_t filesize = 0;
+ long filesize = 0;
FILE *fp = fopen(iter->value_str, "rb");
if (fp) {
fseek(fp, 0, SEEK_END);
diff --git a/plugins/SendScreenshotPlus/src/CSend.h b/plugins/SendScreenshotPlus/src/CSend.h
index fc7985574a..dee2e01dc3 100644
--- a/plugins/SendScreenshotPlus/src/CSend.h
+++ b/plugins/SendScreenshotPlus/src/CSend.h
@@ -98,7 +98,7 @@ protected:
wchar_t* m_ErrorMsg;
wchar_t* m_ErrorTitle;
- MHttpRequest m_nlhr;
+ std::unique_ptr<MHttpRequest> m_pRequest;
void Unhook(){if(m_hOnSend) {UnhookEvent(m_hOnSend);m_hOnSend = nullptr;}}
void DB_EventAdd(uint16_t EventType);
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
index 981c18f399..ec4c9203f1 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
@@ -50,7 +50,8 @@ int CSendHost_ImageShack::Send()
Exit(ACKRESULT_FAILED);
return !m_bAsync;
}
- memset(&m_nlhr, 0, sizeof(m_nlhr));
+
+ m_pRequest.reset(new MHttpRequest(REQUEST_POST));
char* tmp; tmp = mir_u2a(m_pszFile);
HTTPFormData frm[] = {
// { "Referer", HTTPFORM_HEADER("http://www.imageshack.us/upload_api.php") },
@@ -59,7 +60,7 @@ int CSendHost_ImageShack::Send()
{ "public", "no" },
{ "key", HTTPFORM_8BIT(DEVKEY_IMAGESHACK) },
};
- int error = HTTPFormCreate(&m_nlhr, "http://imageshack.us/upload_api.php", frm, sizeof(frm) / sizeof(HTTPFormData));
+ int error = HTTPFormCreate(m_pRequest.get(), "http://imageshack.us/upload_api.php", frm, sizeof(frm) / sizeof(HTTPFormData));
mir_free(tmp);
if (error)
return !m_bAsync;
@@ -75,7 +76,7 @@ int CSendHost_ImageShack::Send()
void CSendHost_ImageShack::SendThread()
{
// send DATA and wait for m_nlreply
- NLHR_PTR reply(Netlib_HttpTransaction(g_hNetlibUser, &m_nlhr));
+ NLHR_PTR reply(Netlib_HttpTransaction(g_hNetlibUser, m_pRequest.get()));
if (reply) {
if (reply->resultCode >= 200 && reply->resultCode < 300 && reply->body.GetLength()) {
const char* url = nullptr;
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp
index b5bd858ab5..9352e29de6 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp
@@ -35,14 +35,15 @@ int CSendHost_Imgur::Send()
Exit(ACKRESULT_FAILED);
return !m_bAsync;
}
- memset(&m_nlhr, 0, sizeof(m_nlhr));
+
+ m_pRequest.reset(new MHttpRequest(REQUEST_POST));
char* tmp; tmp = mir_u2a(m_pszFile);
HTTPFormData frm[] = {
{ "Authorization", HTTPFORM_HEADER("Client-ID 2a7303d78abe041") },
{ "image", HTTPFORM_FILE(tmp) },
};
- int error = HTTPFormCreate(&m_nlhr, "https://api.imgur.com/3/image", frm, _countof(frm));
+ int error = HTTPFormCreate(m_pRequest.get(), "https://api.imgur.com/3/image", frm, _countof(frm));
mir_free(tmp);
if (error)
return !m_bAsync;
@@ -59,7 +60,7 @@ void CSendHost_Imgur::SendThread(void* obj)
{
CSendHost_Imgur *self = (CSendHost_Imgur*)obj;
// send DATA and wait for m_nlreply
- NLHR_PTR reply(Netlib_HttpTransaction(g_hNetlibUser, &self->m_nlhr));
+ NLHR_PTR reply(Netlib_HttpTransaction(g_hNetlibUser, self->m_pRequest.get()));
if (reply) {
if (reply->body.GetLength()) {
JSONROOT root(reply->body);
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
index a19d6ebc06..bd44dfd008 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
@@ -38,7 +38,8 @@ int CSendHost_UploadPie::Send()
Exit(ACKRESULT_FAILED);
return !m_bAsync;
}
- memset(&m_nlhr, 0, sizeof(m_nlhr));
+
+ m_pRequest.reset(new MHttpRequest(REQUEST_POST));
char* tmp; tmp = mir_u2a(m_pszFile);
HTTPFormData frm[] = {
{ "MAX_FILE_SIZE", HTTPFORM_INT(3145728) },
@@ -47,7 +48,7 @@ int CSendHost_UploadPie::Send()
{ "expire", HTTPFORM_INT(m_expire) },
};
- int error = HTTPFormCreate(&m_nlhr, kHostURL, frm, _countof(frm));
+ int error = HTTPFormCreate(m_pRequest.get(), kHostURL, frm, _countof(frm));
mir_free(tmp);
if (error)
return !m_bAsync;
@@ -65,7 +66,7 @@ void CSendHost_UploadPie::SendThread(void* obj)
{
CSendHost_UploadPie* self = (CSendHost_UploadPie*)obj;
// send DATA and wait for m_nlreply
- NLHR_PTR reply(Netlib_HttpTransaction(g_hNetlibUser, &self->m_nlhr));
+ NLHR_PTR reply(Netlib_HttpTransaction(g_hNetlibUser, self->m_pRequest.get()));
if (reply) {
if (reply->resultCode >= 200 && reply->resultCode < 300 && reply->body.GetLength()) {
char* url = reply->body.GetBuffer();
diff --git a/plugins/SendScreenshotPlus/src/stdafx.h b/plugins/SendScreenshotPlus/src/stdafx.h
index 9ad3f6478d..e2c570c370 100644
--- a/plugins/SendScreenshotPlus/src/stdafx.h
+++ b/plugins/SendScreenshotPlus/src/stdafx.h
@@ -40,6 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <UxTheme.h>
#include <map>
+#include <memory>
#include <string>
using namespace std;
diff --git a/plugins/SendScreenshotPlus/src/version.h b/plugins/SendScreenshotPlus/src/version.h
index 3c4cb51959..dd8c6ef385 100644
--- a/plugins/SendScreenshotPlus/src/version.h
+++ b/plugins/SendScreenshotPlus/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 9
#define __RELEASE_NUM 0
-#define __BUILD_NUM 2
+#define __BUILD_NUM 3
#include <stdver.h>