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
This commit is contained in:
rfm 2011-08-15 08:59:52 +00:00
parent 16657e5ff4
commit bc7be959e5

View file

@ -2580,7 +2580,8 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
while (done == NO) while (done == NO)
{ {
BOOL found = NO; BOOL found = NO;
NSUInteger eol = len;
/* /*
* Search data for the next boundary. * Search data for the next boundary.
@ -2594,7 +2595,6 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|| buf[lineStart-1] == '\n') || buf[lineStart-1] == '\n')
{ {
BOOL lastPart = NO; BOOL lastPart = NO;
NSUInteger eol;
lineEnd = lineStart + bLength; lineEnd = lineStart + bLength;
eol = lineEnd; eol = lineEnd;
@ -2620,6 +2620,7 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
} }
if (eol < len && buf[eol] == '\n') if (eol < len && buf[eol] == '\n')
{ {
eol++;
flags.wantEndOfLine = 0; flags.wantEndOfLine = 0;
found = YES; found = YES;
endedFinalPart = lastPart; endedFinalPart = lastPart;
@ -2771,6 +2772,16 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
sectionStart = lineStart; sectionStart = lineStart;
if (endedFinalPart == YES) 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; lineStart = sectionStart = 0;
[data setLength: 0]; [data setLength: 0];
done = YES; done = YES;