Skip to content

Commit

Permalink
Fix growbuffer_append
Browse files Browse the repository at this point in the history
This fixes the following error encountered when uploading large files:

ERROR: ErrorMalformedXML
  Message: The XML you provided was not well-formed or did not
  validate against our published schema.

This becomes a problem after a previous patch increases the size limit for a single object, causing more than one growbuffer to be allocated for holding the XML.
  • Loading branch information
meinemitternacht authored Aug 21, 2018
1 parent f9c5fb8 commit 6913723
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ typedef struct growbuffer
// returns nonzero on success, zero on out of memory
static int growbuffer_append(growbuffer **gb, const char *data, int dataLen)
{
int toCopy = 0 ;
int origDataLen = dataLen;
while (dataLen) {
growbuffer *buf = *gb ? (*gb)->prev : 0;
if (!buf || (buf->size == sizeof(buf->data))) {
Expand All @@ -448,7 +448,7 @@ static int growbuffer_append(growbuffer **gb, const char *data, int dataLen)
}
}

toCopy = (sizeof(buf->data) - buf->size);
int toCopy = (sizeof(buf->data) - buf->size);
if (toCopy > dataLen) {
toCopy = dataLen;
}
Expand All @@ -458,7 +458,7 @@ static int growbuffer_append(growbuffer **gb, const char *data, int dataLen)
buf->size += toCopy, data += toCopy, dataLen -= toCopy;
}

return toCopy;
return origDataLen;
}


Expand Down

0 comments on commit 6913723

Please sign in to comment.