Fix problem parsing chunked data.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8581 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2001-01-13 08:05:30 +00:00
parent ead63e6999
commit 23b40dc703
2 changed files with 20 additions and 3 deletions

View file

@ -1,3 +1,10 @@
2001-01-13 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSMime.m: ([-decodeData:fromrange:intoData:withContext:])
Added destination data cpacity information to context so that
correct positioning can be maintained over a sequence of calls
using a chunked http context.
2001-01-12 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSXML.m: ([-GSXMLDocument setRoot:]) set root node to be

View file

@ -236,13 +236,14 @@ parseCharacterSet(NSString *token)
unsigned pos;
enum {
ChunkSize, // Reading chunk size
ChunkExt, // Reading cjhunk extensions
ChunkExt, // Reading chunk extensions
ChunkEol1, // Reading end of line after size;ext
ChunkData, // Reading chunk data
ChunkEol2, // Reading end of line after data
ChunkFoot, // Reading chunk footer after newline
ChunkFootA // Reading chunk footer
} state;
unsigned size; // Size of buffer required.
NSMutableData *data;
}
@end
@ -546,7 +547,15 @@ parseCharacterSet(NSString *token)
ctxt = (GSMimeChunkedDecoderContext*)con;
dst = beg = 0;
beg = 0;
/*
* Make sure buffer is big enough, and set up output pointers.
*/
[dData setLength: ctxt->size];
dst = (unsigned char*)[dData mutableBytes];
dst = dst + size;
beg = dst;
while ([ctxt atEnd] == NO && src < end)
{
switch (ctxt->state)
@ -597,7 +606,8 @@ parseCharacterSet(NSString *token)
* the buffer for another chunk.
*/
size += (dst - beg);
[dData setLength: size + val];
ctxt->size = size + val;
[dData setLength: ctxt->size];
dst = (unsigned char*)[dData mutableBytes];
dst += size;
beg = dst;