curl-library
Re: malformed multipart/form-data with zero-byte section?
Date: Mon, 25 Oct 2004 00:25:40 +0200 (CEST)
On Sun, 24 Oct 2004, Mohun Biswas wrote:
> This has worked fine for quite a while but I just ran into a special case.
> When the file to be uploaded has zero length the FileUpload parser hangs on
> the server side. A little network tracing reveals that zero-length files
> uploaded via the code above have no closing boundary delimiter.
I could easily repeat this problem, and this patch seems to correct it for me:
--- lib/formdata.c 8 Oct 2004 08:18:08 -0000 1.81
+++ lib/formdata.c 24 Oct 2004 22:24:23 -0000
@@ -1307,9 +1307,13 @@
if(!form->data)
return 0; /* nothing, error, empty */
- if(form->data->type == FORM_FILE)
- return readfromfile(form, buffer, wantedsize);
+ if(form->data->type == FORM_FILE) {
+ gotsize = readfromfile(form, buffer, wantedsize);
+ if(gotsize)
+ /* If positive or -1, return. If zero, continue! */
+ return gotsize;
+ }
do {
if( (form->data->length - form->sent ) > wantedsize - gotsize) {
-- Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se Dedicated custom curl help for hire: http://haxx.se/curl.htmlReceived on 2004-10-25