From 5baafa881a2ec9206eeac155fe4bfc0659c2af5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Sch=C3=BCmann?= Date: Sun, 8 Jun 2014 01:10:33 +0000 Subject: SendSS: ! fixed possible crash (CSendHost_uploadpie, CSendImageShack) * improved ImageShack error handling by improving GetHTMLContent * improved uploadpie error handling (still ugly, but better non the less) git-svn-id: http://svn.miranda-ng.org/main/trunk@9421 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SendScreenshotPlus/src/CSend.cpp | 9 ++++++--- plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp | 15 +++++++++------ plugins/SendScreenshotPlus/src/CSendImageShack.cpp | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'plugins/SendScreenshotPlus/src') diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp index a2f8e51beb..f0c800004e 100644 --- a/plugins/SendScreenshotPlus/src/CSend.cpp +++ b/plugins/SendScreenshotPlus/src/CSend.cpp @@ -454,9 +454,12 @@ void CSend::Exit(unsigned int Result) { const char* CSend::GetHTMLContent(char* str, const char* startTag, const char* endTag) { char* begin=strstr(str,startTag); if(!begin) return NULL; - begin+=strlen(startTag); - char* end=strstr(begin,endTag); - if(end) *end=0; + begin+=strlen(startTag)-1; + for(; *begin!='>' && *begin; ++begin); + if(*begin){ + char* end=strstr(++begin,endTag); + if(end) *end=0; + } return begin; } diff --git a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp index 0218956559..6a2c7fe48a 100644 --- a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp +++ b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp @@ -67,8 +67,8 @@ void CSendHost_UploadPie::SendThread(void* obj) NETLIBHTTPREQUEST* reply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlibUser,(LPARAM)&self->m_nlhr); self->HTTPFormDestroy(&self->m_nlhr); if(reply){ - if(reply->resultCode>=200 && reply->resultCode<300){ - reply->pData[reply->dataLength]='\0';/// make sure its null terminated + if(reply->resultCode>=200 && reply->resultCode<300 && reply->dataLength){ + reply->pData[reply->dataLength-1]='\0';/// make sure its null terminated char* url=reply->pData; do{ char* pos; @@ -76,7 +76,7 @@ void CSendHost_UploadPie::SendThread(void* obj) for(pos=url+21; (*pos>='0'&&*pos<='9') || (*pos>='a'&&*pos<='z') || (*pos>='A'&&*pos<='Z') || *pos=='_' || *pos=='-' || *pos=='"' || *pos=='\''; ++pos){ if(*pos=='"' || *pos=='\'') break; } - if(*pos=='"' || *pos=='\''){ + if(url+21!=pos && (*pos=='"' || *pos=='\'')){ *pos='\0'; break; } @@ -88,9 +88,12 @@ void CSendHost_UploadPie::SendThread(void* obj) CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)reply); self->svcSendMsgExit(url); return; }else{/// check error mess from server - TCHAR* err=mir_a2t(reply->pData); - self->Error(_T("%s"),err); - mir_free(err); + const char* err=GetHTMLContent(reply->pData,"

"); + TCHAR* werr; + if(err) werr=mir_a2t(err); + else werr=mir_a2t(reply->pData); + self->Error(_T("%s"),werr); + mir_free(werr); } }else{ self->Error(LPGENT("Upload server did not respond timely.")); diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp index c12eed48fe..9bd0ef0e0f 100644 --- a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp +++ b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp @@ -72,8 +72,8 @@ void CSendImageShack::SendThread() { NETLIBHTTPREQUEST* reply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&m_nlhr); HTTPFormDestroy(&m_nlhr); if(reply){ - if(reply->resultCode>=200 && reply->resultCode<300){ - reply->pData[reply->dataLength]='\0';/// make sure its null terminated + if(reply->resultCode>=200 && reply->resultCode<300 && reply->dataLength){ + reply->pData[reply->dataLength-1]='\0';/// make sure its null terminated const char* url=NULL; url=GetHTMLContent(reply->pData,"",""); if(url && *url){ -- cgit v1.2.3