From 53e568efe6f2a9e121ac6cf305e5fa9a84137c1a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 3 Jan 2013 22:11:27 +0000 Subject: - fix for the buffer overrun in YAMN's mime parser - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@2948 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/YAMN/src/mails/decode.cpp | 8 +++--- plugins/YAMN/src/mails/mails.cpp | 4 +-- plugins/YAMN/src/mails/mime.cpp | 55 ++++++++++++++++++++------------------- 3 files changed, 34 insertions(+), 33 deletions(-) (limited to 'plugins/YAMN/src/mails') diff --git a/plugins/YAMN/src/mails/decode.cpp b/plugins/YAMN/src/mails/decode.cpp index 867ed7ff25..3af1edc056 100644 --- a/plugins/YAMN/src/mails/decode.cpp +++ b/plugins/YAMN/src/mails/decode.cpp @@ -303,13 +303,13 @@ int DecodeQuotedPrintable(char *Src,char *Dst,int DstLen, BOOL isQ) for (int Counter=0;((char)*Src!=0) && DstLen && (Counter++MailFcn!=NULL){ + if (Plugin->MailFcn!=NULL) { if (Plugin->MailFcn->DeleteMailFcnPtr!=NULL) { //Let plugin delete its own CMimeMsgQueue derived structure Plugin->MailFcn->DeleteMailFcnPtr(OldMail); @@ -435,7 +435,7 @@ void WINAPI TranslateHeaderFcn(char *stream,int len,struct CMimeItem **head) while (!DOTLINE(finder+1))finder++; if (ENDLINE(finder))finder--; prev2 = finder; - if (prev2>prev1){ // yes, we have body + if (prev2>prev1) { // yes, we have body if (NULL==(Item->Next=new struct CMimeItem)) break; // Cant create new item?! Item=Item->Next; Item->Next=NULL;//just in case; diff --git a/plugins/YAMN/src/mails/mime.cpp b/plugins/YAMN/src/mails/mime.cpp index 2a66b80e2b..7b00979cad 100644 --- a/plugins/YAMN/src/mails/mime.cpp +++ b/plugins/YAMN/src/mails/mime.cpp @@ -201,7 +201,7 @@ char *ExtractFromContentType(char *ContentType,char *value) char *lowered = _strdup(ContentType); ToLower(lowered); char *finder=strstr(lowered,value); - if (finder==NULL){ + if (finder==NULL) { free (lowered); return NULL; } @@ -531,7 +531,7 @@ void ParseAPart(APartDataType *data) while(ENDLINEWS(finder)) finder++; //at the start of line - if (finder>data->Src){ + if (finder>data->Src) { if (*(finder-2)=='\r' || *(finder-2)=='\n') *(finder-2)=0; if (*(finder-1)=='\r' || *(finder-1)=='\n') @@ -572,7 +572,7 @@ void ParseAPart(APartDataType *data) finder++; if (ENDLINE(finder)) { // end of headers. message body begins - if (finder>data->Src){ + if (finder>data->Src) { if (*(finder-2)=='\r' || *(finder-2)=='\n') *(finder-2)=0; if (*(finder-1)=='\r' || *(finder-1)=='\n') @@ -584,7 +584,7 @@ void ParseAPart(APartDataType *data) while (!EOS(finder+1))finder++; if (ENDLINE(finder))finder--; prev2 = finder; - if (prev2>prev1){ // yes, we have body + if (prev2>prev1) { // yes, we have body data->body = prev1; } break; // there is nothing else @@ -616,7 +616,7 @@ WCHAR *ParseMultipartBody(char *src, char *bond) APartDataType *partData = new APartDataType[numparts]; memset(partData, 0, sizeof(APartDataType)*numparts); partData[0].Src = courbond = srcback; - for (i=1;(courbond=strstr(courbond,bond));i++,courbond+=sizebond){ + for (i=1;(courbond=strstr(courbond,bond));i++,courbond+=sizebond) { *(courbond-2) = 0; partData[i].Src = courbond+sizebond; while (ENDLINE(partData[i].Src)) partData[i].Src++; @@ -624,12 +624,12 @@ WCHAR *ParseMultipartBody(char *src, char *bond) size_t resultSize=0; for (i=0;i