From bc7be959e5ee70d302ad92171742295ec3f83a80 Mon Sep 17 00:00:00 2001 From: rfm Date: Mon, 15 Aug 2011 08:59:52 +0000 Subject: [PATCH] fix detection of excess data at end of multipart docs git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33738 72102866-910b-0410-8b05-ffd578937521 --- Source/Additions/GSMime.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Source/Additions/GSMime.m b/Source/Additions/GSMime.m index 9157ac28d..58b153800 100644 --- a/Source/Additions/GSMime.m +++ b/Source/Additions/GSMime.m @@ -2580,7 +2580,8 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info); while (done == NO) { - BOOL found = NO; + BOOL found = NO; + NSUInteger eol = len; /* * Search data for the next boundary. @@ -2594,7 +2595,6 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info); || buf[lineStart-1] == '\n') { BOOL lastPart = NO; - NSUInteger eol; lineEnd = lineStart + bLength; eol = lineEnd; @@ -2620,6 +2620,7 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info); } if (eol < len && buf[eol] == '\n') { + eol++; flags.wantEndOfLine = 0; found = YES; endedFinalPart = lastPart; @@ -2771,6 +2772,16 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info); sectionStart = lineStart; if (endedFinalPart == YES) { + if (eol < len) + { + NSData *excess; + + excess = [[NSData alloc] initWithBytes: buf + eol + length: len - eol]; + ASSIGN(boundary, excess); + flags.excessData = 1; + [excess release]; + } lineStart = sectionStart = 0; [data setLength: 0]; done = YES;